Fix AttributeError when deleting vectors in asyncio mode#610
Open
veeceey wants to merge 2 commits intopinecone-io:mainfrom
Open
Fix AttributeError when deleting vectors in asyncio mode#610veeceey wants to merge 2 commits intopinecone-io:mainfrom
veeceey wants to merge 2 commits intopinecone-io:mainfrom
Conversation
Fixes pinecone-io#564 The asyncio SDK was throwing AttributeError when attempting to delete vectors because the code tried to set '_response_info' attribute on primitive types (like strings) which don't support dynamic attribute assignment. Root Cause: The delete operation returns a string response, but the code assumed all non-dict responses were OpenAPI model objects that support setattr. Fix: Added type check to skip setting '_response_info' on primitive types (str, int, float, bool, None) which don't support dynamic attributes. Only OpenAPI model objects and dicts now get the response info attached. Changes: - asyncio_api_client.py: Added isinstance check for primitive types - api_client.py: Applied same fix to sync client for consistency The fix allows the delete operation to succeed without attempting to modify immutable primitive types, while still preserving response info attachment for complex types that support it. Manual Testing: Using the reproduction script from the issue: 1. Create index 2. Upsert vectors 3. Delete vectors with asyncio (previously failed, now succeeds) 4. Clean up index Signed-off-by: Varun Chawla <varun_6april@hotmail.com>
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
Bugbot Autofix is OFF. To automatically fix reported issues with Cloud Agents, enable Autofix in the Cursor dashboard.
The original fix only checked for str, int, float, bool, and None, but responses can also be list, tuple, or bytes types which also don't support arbitrary setattr(). This aligns with the codebase's PRIMITIVE_TYPES definition and prevents AttributeError for list-typed API responses.
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
The asyncio SDK was throwing
AttributeError: 'str' object has no attribute '_response_info'when attempting to delete vectors. This bug prevented the use of asyncio delete operations.Root Cause
The delete operation returns a simple string response, but the API client code assumed all non-dict responses were OpenAPI model objects that support dynamic attribute assignment via
setattr().The problematic code:
Solution
Added type checking to skip primitive types that don't support
setattr():Changes
setattr()Testing
Reproduction Script (from issue #564):
Expected Behavior: Delete completes successfully without errors
Actual Behavior (before fix):
AttributeError: 'str' object has no attribute '_response_info'Actual Behavior (after fix): Delete succeeds
Impact
Environment
Note
Low Risk
Small, localized change to response post-processing that only adds a type guard around
setattr(); low risk aside from slightly reduced_response_infoattachment on primitive return types.Overview
Prevents
AttributeErrorwhen endpoints return primitive types (e.g.,str) by skipping_response_infoattachment viasetattr()for non-model responses.Applies the same primitive-type guard in both
asyncio_api_client.pyandapi_client.py, while preserving_response_infoinjection fordictresponses and OpenAPI model objects.Written by Cursor Bugbot for commit bdc4bba. This will update automatically on new commits. Configure here.