Repository navigation
fix: encode spaces as %20 in query parameters instead of + - #710
Open
themanoj-025 wants to merge 1 commit into
Open
themanoj-025 wants to merge 1 commit into
themanoj-025 wants to merge 1 commit into
Conversation
Signed-off-by: Manoj Jana <[email protected]>
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
In v9+, after transitioning to
httpx, requests with query parameters (such as/vectors/fetch,/vectors/list, and/namespaces) converted spaces in IDs or namespaces to+rather than%20(regression of #372). Because Pinecone treats+as a literal character, passing IDs or namespaces containing spaces (e.g.doc 42,my namespace) resulted in empty results or missing records.Root Cause
httpxencodes query parameters usingurllib.parse.urlencodewith its defaultquote_via=quote_plus, converting spaces to+. When passing query parameters viaparams=...tohttpx.Clientorhttpx.AsyncClient,httpxinternally re-encodes query parameters usingquote_plus.Solution
_encode_query_paramsinpinecone/_internal/http_client.pyusingurllib.parse.urlencode(..., doseq=True, quote_via=urllib.parse.quote)so spaces are RFC 3986 percent-encoded as%20and literal plus signs are encoded as%2B._prepare_path_and_kwargsto merge encoded query parameters directly onto the requestpath, preserving%20on the wire for both sync (HTTPClient) and async (AsyncHTTPClient) methods.tests/unit/test_query_param_spaces_705.pycovering:ids=doc%2042&ids=doc%2B42).test_query_param_enums_371.py).Note
Medium Risk
Touches the central HTTP client request path for all REST calls with query parameters; behavior change is intentional but affects every endpoint that passes
params=.Overview
Fixes a regression where httpx sent query values with spaces as
+, while Pinecone treats+literally—so fetch/list/delete on namespaces or vector IDs containing spaces (e.g.doc 42) could return nothing (#705).The HTTP layer now RFC 3986-encodes query parameters with
%20for spaces (and%2Bfor literal plus signs) via new_encode_query_params, then appends that string to the request path through_prepare_path_and_kwargsinstead of handingparams=to httpx (which re-encodes withquote_plus). Sync and asyncget/put/patch/deleteand the POST slow path use this flow; enum resolution for params is preserved inside the encoder.Adds
tests/unit/test_query_param_spaces_705.pyto assert the on-the-wire path for sync/async GET and DELETE with spaced namespaces and mixedids.Reviewed by Cursor Bugbot for commit 94293e4. Bugbot is set up for automated code reviews on this repo. Configure here.