Skip to content

fix: avoid bool-checking query namespace vectors#667

Open
pragnyanramtha wants to merge 1 commit into
pinecone-io:mainfrom
pragnyanramtha:pragnyan/fix-query-namespaces-vector-truthiness
Open

fix: avoid bool-checking query namespace vectors#667
pragnyanramtha wants to merge 1 commit into
pinecone-io:mainfrom
pragnyanramtha:pragnyan/fix-query-namespaces-vector-truthiness

Conversation

@pragnyanramtha
Copy link
Copy Markdown

@pragnyanramtha pragnyanramtha commented May 16, 2026

Summary

  • avoid boolean-coercing dense vectors in sync and async query_namespaces() validation
  • preserve existing empty-vector validation while allowing sequence-like vectors with ambiguous truth values
  • add sync and async regression tests that assert vectors are passed through to query() unchanged

Validation

  • uv run --no-sync pytest tests/unit/test_query_namespaces.py tests/unit/test_async_query_namespaces.py tests/unit/async_client/test_async_index_query_namespaces.py -q (34 passed)
  • uv run --no-sync ruff check pinecone/index/__init__.py pinecone/async_client/async_index.py tests/unit/test_query_namespaces.py tests/unit/test_async_query_namespaces.py
  • uv run --no-sync ruff format --check pinecone/index/__init__.py pinecone/async_client/async_index.py tests/unit/test_query_namespaces.py tests/unit/test_async_query_namespaces.py
  • uv run --no-sync mypy --strict pinecone/index/__init__.py pinecone/async_client/async_index.py
  • git diff --check

Note: a full editable project build was not run locally because this machine does not have protoc; CI installs protoc before building the Rust extension.


Note

Low Risk
Low risk: small validation tweak in query_namespaces() to treat only None/empty dense vectors as missing while avoiding __bool__ evaluation; covered by new sync/async regression tests.

Overview
Fixes Index.query_namespaces() and AsyncIndex.query_namespaces() validation to stop boolean-coercing the provided dense vector, checking explicitly for None or len(vector)==0 instead.

Adds sync and async unit tests using a sequence-like vector with an ambiguous truth value to ensure the vector is accepted and forwarded through to query() unchanged, while preserving the existing empty-vector error behavior.

Reviewed by Cursor Bugbot for commit 46e94fb. Bugbot is set up for automated code reviews on this repo. Configure here.

@pragnyanramtha pragnyanramtha marked this pull request as ready for review May 16, 2026 16:29
Copilot AI review requested due to automatic review settings May 16, 2026 16:29
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot encountered an error and was unable to review this pull request. You can try again by re-requesting a review.

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.

2 participants