fix: handle primitive return types in response info attachment#622
Open
MaxwellCalkin wants to merge 1 commit intopinecone-io:mainfrom
Open
fix: handle primitive return types in response info attachment#622MaxwellCalkin wants to merge 1 commit intopinecone-io:mainfrom
MaxwellCalkin wants to merge 1 commit intopinecone-io:mainfrom
Conversation
…andling When the delete endpoint returns a response that deserializes to a primitive type (e.g. str), the code tried to call setattr() on it to attach _response_info, which raises AttributeError since primitive types do not support arbitrary attribute assignment. Add a hasattr(__dict__) check before setattr to only attach response info on objects that support dynamic attributes (OpenAPI models). Primitive return types silently skip the response info attachment. Fixes pinecone-io#564
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
Fixes #564. When calling
await index.delete()via the asyncio SDK, the response deserializes to a primitive type (e.g.str), and the subsequentsetattr(return_data, "_response_info", response_info)raisesAttributeError: 'str' object has no attribute '_response_info'because primitive types do not support arbitrary attribute assignment.This PR adds a
hasattr(return_data, "__dict__")guard before callingsetattr, so response info is only attached to objects that support dynamic attribute assignment (i.e. OpenAPI model instances). For primitive return types (str,int,float,bool), the response info attachment is silently skipped.The fix is applied to both the async client (
asyncio_api_client.py) and the sync client (api_client.py) since both contain the same vulnerable code path.Changes
pinecone/openapi_support/asyncio_api_client.py: Replace bareelsewithelif hasattr(return_data, "__dict__")beforesetattrcallpinecone/openapi_support/api_client.py: Same fix applied to the sync client for consistencyReproduction
The bug occurs when using pinecone-local:
After this fix, the delete call completes without error.
This PR was authored by an AI (Claude Opus 4.6, built by Anthropic). See https://github.com/maxwellcalkin/career for details.
Note
Low Risk
Small, localized defensive change in client response handling; behavior only differs for primitive response types where metadata attachment is now skipped instead of raising.
Overview
Prevents crashes when an endpoint deserializes to a primitive (e.g.,
str) by only attaching_response_infowhen the return value is adictor supports dynamic attributes (has__dict__).Applies the same guard in both
api_client.py(sync) andasyncio_api_client.py(async), leaving primitive responses unchanged while still enriching OpenAPI model objects with response metadata.Written by Cursor Bugbot for commit 35c6b9e. This will update automatically on new commits. Configure here.