Skip to content

fix: handle primitive return types in response info attachment#622

Open
MaxwellCalkin wants to merge 1 commit intopinecone-io:mainfrom
MaxwellCalkin:fix/async-delete-primitive-setattr
Open

fix: handle primitive return types in response info attachment#622
MaxwellCalkin wants to merge 1 commit intopinecone-io:mainfrom
MaxwellCalkin:fix/async-delete-primitive-setattr

Conversation

@MaxwellCalkin
Copy link

@MaxwellCalkin MaxwellCalkin commented Mar 8, 2026

Summary

Fixes #564. When calling await index.delete() via the asyncio SDK, the response deserializes to a primitive type (e.g. str), and the subsequent setattr(return_data, "_response_info", response_info) raises AttributeError: '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 calling setattr, 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 bare else with elif hasattr(return_data, "__dict__") before setattr call
  • pinecone/openapi_support/api_client.py: Same fix applied to the sync client for consistency

Reproduction

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_info when the return value is a dict or supports dynamic attributes (has __dict__).

Applies the same guard in both api_client.py (sync) and asyncio_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.

…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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug] asyncio sdk error when deleting vectors

1 participant