Repository navigation
fix(http): percent-encode spaces as %20 instead of + in query parameters - #709
Open
industriverse wants to merge 1 commit into
Open
industriverse wants to merge 1 commit into
industriverse wants to merge 1 commit into
Conversation
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.
Summary
_encode_query_params()and_prepare_url_and_params()inpinecone/_internal/http_client.pyand routed all sync (HTTPClient) and async (AsyncHTTPClient) verbs through them.urllib.parse.quote(..., safe="")(encoding spaces as%20and literal+as%2B) after normalizing values throughhttpx.QueryParams(preserving enum resolution from Readme changes for v5 release. #371, boolean lowercase formatting, and repeated keys), then attaches the encoded query string to the request path sohttpxdoes not re-encode%20back into+.fetch,list_paginated, andlist_namespaces_paginatedwhen IDs, namespaces, or prefixes contain spaces.Testing
tests/unit/test_query_param_space_encoding_705.pycovering sync/asyncHTTPClient, existing query strings, literal+preservation, and end-to-endIndex.fetch/Index.list_paginated/Index.list_namespaces_paginated/IndexAsyncio.fetch.pytest tests/unit/test_query_param_space_encoding_705.py tests/unit/test_query_param_enums_371.py tests/unit/_internal/test_http_client.py tests/unit/_internal/test_http_client_curl_debug.py— 41 passed.Note
Medium Risk
Central change to how every GET/DELETE and param-bearing POST/PUT/PATCH URL is built; wrong encoding could break lookups for edge-case identifiers, though scope is limited to query serialization and behavior is covered by new tests.
Overview
Fixes #705 by changing how the SDK builds query strings for REST calls. httpx was encoding spaces as
+(form-urlencoded style); Pinecone index endpoints expect RFC 3986%20, so fetches/lists with spaces in IDs, namespaces, or prefixes could miss on the server.The PR adds
_encode_query_params(normalize viahttpx.QueryParams, thenurlencodewithquote/safe="") and_prepare_url_and_params, which merges that string onto the request path and dropsparamsfrom kwargs so httpx does not rewrite%20back to+. Sync and asyncHTTPClientverbs that acceptparamsnow go through this path; enum resolution from_prepare_paramsis unchanged. POST’s json-only fast path is untouched.New unit tests in
test_query_param_space_encoding_705.pyassert%20encoding, literal+as%2B, merging with an existing?query=, and end-to-endIndex/IndexAsynciofetch/list paths.Reviewed by Cursor Bugbot for commit e4f6ba0. Bugbot is set up for automated code reviews on this repo. Configure here.