fix: correct TextQuery and VectorQuery API serialization #587
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 unresolved review comments from PR #586 that were merged without being addressed.
Related PR: #586
Problems Fixed
1. Wrong API field name in
TextQuery(High Severity)The
as_dict()method was serializing the query string with key"query", but the Pinecone API expects"text_query"as defined in the OpenAPI spec.2. Missing
typediscriminator field (High Severity)Both
TextQueryandVectorQuerywere missing the requiredtypediscriminator field used by theScoreByQueryoneOf schema:TextQuery→"type": "text"VectorQuery→"type": "vector"3. Inconsistent method naming (Low Severity)
Changed
to_dict()toas_dict()for consistency with similar search-related classes (SearchQuery,SearchQueryVector,SearchRerank).Breaking Changes
Since these classes were just added in PR #586 and haven't been released yet, these changes should not affect any users:
TextQuery.to_dict()→TextQuery.as_dict()VectorQuery.to_dict()→VectorQuery.as_dict()Usage Example
Test Plan
typediscriminatoras_dict()method nameNote
Medium Risk
Medium risk because it changes the serialized request shape and renames a public method (
to_dict()→as_dict()), which can break any existing callers even though the change is localized.Overview
Fixes
TextQueryandVectorQueryAPI serialization used byscore_byby adding the requiredtypediscriminator ("text"/"vector") and aligning field names (notablyquery→text_queryfor text scoring).Renames the serialization helper from
to_dict()toas_dict()on both classes and updates unit tests to assert the new payload format and method name.Written by Cursor Bugbot for commit 50ee953. This will update automatically on new commits. Configure here.