Repository navigation
Conversation
httpx encodes a space in a query value as '+', which the Pinecone API reads as a literal plus sign. fetch(), list_paginated() and list_namespaces(prefix=...) therefore found nothing for IDs or namespaces containing a space. Encode params= into the request path so spaces go out as %20, as they did before the move to httpx. Fixes pinecone-io#705
This branch has not been deployed
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.
Fixes #705
Problem
httpx encodes a space in a query value as
+. The Pinecone API reads+as a literal plus sign, sofetch(ids=["doc 42"])asked fordoc+42, and a namespace namedmy nswas looked up asmy+ns.fetch,list_paginatedandlist_namespaces(prefix=...)found nothing and raised no error. 8.1.2 sent%20(#372); the move to httpx in 9.0.0 lost that.Fix
httpx has no option to choose this encoding for
params=, soHTTPClientandAsyncHTTPClientnow encodeparams=themselves and append it to the request path, which httpx leaves as written (new helper_fold_params_into_path). The encoding is httpx's own, with spaces written as%20.urlencodealready writes a real+as%2B, so a literal plus is still sent as%2B. Enum members are still resolved first. This covers everyget/post/put/patch/deletethat passesparams=, sync and async, not only the three calls from the report. Thepostfast path (JSON body only) is unchanged.Tests
New
tests/unit/test_query_param_space_encoding_705.py(20 tests) checks the raw request target for all five verbs on both clients, a literal+and%staying distinct from a space, enum resolution, params added to a query already in the path, empty params, andfetch,list_paginatedandlist_namespaces(prefix=...)onIndexandAsyncIndex. 18 of the 20 fail onmainwithout the change and pass with it. The other 2 cover behaviour that was already correct and must stay that way.Run locally:
pytest tests/unit: 11152 passed, 3 skippedruff check,ruff format --checkandmypyonpineconeand the new test file: cleanI did not run the integration tests, as they need a live API key.
Note
Medium Risk
Central HTTP-layer change affects all requests that pass
params=; incorrect encoding could break lookups, but behavior is narrowly scoped and heavily unit-tested.Overview
Fixes #705: query parameters with spaces were sent as
+(httpx default) while Pinecone treats+as a literal plus, so namespaces/IDs like"my ns"or"doc 42"silently failed to match after the 9.0 httpx migration._fold_params_into_pathencodesparams=with httpx’sQueryParams, rewrites+to%20, merges the string onto the request path, and dropsparamsfrom kwargs so httpx does not re-encode. Literal+values stay%2B; enum query values are still normalized via_prepare_params. Wired into every sync/asyncget/post/put/patch/deleteonHTTPClient/AsyncHTTPClient(POST JSON-only fast path unchanged).Adds
tests/unit/test_query_param_space_encoding_705.pywith HTTP-boundary checks for all verbs and end-to-end coverage forfetch,list_paginated, andlist_namespaces(prefix=...)onIndex/AsyncIndex.Reviewed by Cursor Bugbot for commit 9ecbcce. Bugbot is set up for automated code reviews on this repo. Configure here.