Fix AttributeError on delete with non-dict response (#564)#634
Merged
Conversation
When the API returns a primitive type (e.g. str) from delete, setattr fails because primitives don't support dynamic attribute assignment. Guard with hasattr(__dict__) so we only attach _response_info to objects that support it. Adds unit, integration, and pinecone-local repro tests.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Reopens #564 — we previously believed this was fixed, but the earlier fix only handled the case where the server returns an empty response body. We missed the case where the server returns a non-empty string (as pinecone-local does), which still triggered the same
AttributeError: 'str' object has no attribute '_response_info'. We didn't have integration tests covering delete at the time, so the gap went unnoticed. Sorry about that.The root cause is the same:
setattr()is called on the deserialized response data, which fails for primitive types likestrthat don't support dynamic attribute assignment. The fix guards withhasattr(return_data, "__dict__")so we only attach_response_infoto objects that support it.Changes
pinecone/openapi_support/api_client.py— guard setattr on response datapinecone/openapi_support/asyncio_api_client.py— same fix for async clienttests/unit/db_data/test_asyncio_delete_bug.py— unit tests for string response bodiestests/integration/rest_asyncio/db/data/test_delete.py— async integration tests for delete by ids and delete_alltests/integration/rest_sync/db/data/test_delete.py— sync integration tests for delete by ids and delete_allscripts/test_pinecone_local_delete.py— one-off repro script for verifying against pinecone-localTest plan
scripts/test_pinecone_local_delete.py