fix(vector_stores): pass namespace as top-level kwarg to UpstashVector query_many#5202
Conversation
…r query_many The Upstash client's `Index.query_many` takes `namespace` as a top-level keyword argument, and the per-query `QueryRequest` TypedDict has no `namespace` field. Passing `"namespace": self.collection_name` inside each per-query dict caused two failure modes: - Multi-query (`enable_embeddings=False` with multiple vectors): the per-query `namespace` was silently dropped, so every search routed to the default namespace and returned data from the wrong scope. - Single-query: `query_many` internally calls `self.query(**query, namespace=namespace)`, which raised `TypeError: got multiple values for keyword argument 'namespace'`. Move `namespace` from each query dict onto `query_many`'s top-level kwarg, matching the Upstash client signature (upstash_vector.core.index_operations.IndexOperations.query_many, v0.8.0). Closes mem0ai#4207
|
Friendly check-in on this one — the fix is small (move Thanks for taking a look when you get a chance! |
LGTMLinked issue: #4207 (P1-high) — validated The fix is minimal and correct: moves Optional (pre-existing, not introduced by this PR):
Ready for human review and merge. |
Python v2.0.5 additions: - feat: add explain=True search score breakdowns (#5102) - fix(memory): reject empty/whitespace search queries (#5258) - fix(llms/xai): forward tools, add XAIConfig, parse tool_calls (#5190) - fix(pgvector): use open=False to prevent ConnectionPool hang in Docker (#5155) - fix(vector-stores): filter S3 vector list results client-side (#5018) - fix(vector_stores): Upstash namespace passed as top-level kwarg (#5202) TypeScript v3.0.7 additions: - feat: add explain search score breakdowns (#5102) - fix(embeddings): request float encoding_format from OpenAI (#5170)
Linked Issue
Closes #4207
Description
UpstashVector.search()was passingnamespaceinside each per-querydict to
upstash_vector.Index.query_many(). The Upstash client expectsnamespaceas a top-level keyword argument; theQueryRequestTypedDict has no
namespacefield, so the per-query value was silentlydropped and every query routed to the default namespace.
When
len(queries) == 1,query_manyinternally callsself.query(**query, namespace=namespace)— which raisesTypeError: got multiple values for keyword argument 'namespace'becausenamespaceends up bound twice.This PR moves
namespacefrom each query dict ontoquery_many'stop-level kwarg, matching the Upstash client signature
(
upstash_vector.core.index_operations.IndexOperations.query_many,v0.8.0).
Type of Change
Breaking Changes
N/A — this fixes the search path so
enable_embeddings=Falseusersactually receive results from their configured namespace. Users who never
set a custom
collection_namesaw no visible effect; users who did weresilently returned data from the wrong namespace, or hit a
TypeErroronsingle-query search.
Test Coverage
Updated
test_search_vectorsandtest_search_vectors_empty_filterstoassert the new (correct) call shape, and added
test_search_vectors_multi_query_namespace_at_top_levelas a regressiontest that locks in the fix on the multi-query path. The new test was
verified to fail on the buggy code and pass on the fix.
Checklist
bug fix in vector store call shape, no public API change)