Skip to content

fix(http): percent-encode spaces as %20 instead of + in query parameters - #709

Open
industriverse wants to merge 1 commit into
pinecone-io:mainfrom
industriverse:fix/percent-encode-spaces-in-query-params-705
Open

industriverse wants to merge 1 commit into
pinecone-io:mainfrom
industriverse:fix/percent-encode-spaces-in-query-params-705

Conversation

@industriverse

@industriverse industriverse commented Nov 23, 2026 •

Copy link
Copy Markdown

Fixes #705.

Summary

  • Added _encode_query_params() and _prepare_url_and_params() in pinecone/_internal/http_client.py and routed all sync (HTTPClient) and async (AsyncHTTPClient) verbs through them.
  • Serializes query parameters using RFC 3986 urllib.parse.quote(..., safe="") (encoding spaces as %20 and literal + as %2B) after normalizing values through httpx.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 so httpx does not re-encode %20 back into +.
  • Restores v8.x behavior for fetch, list_paginated, and list_namespaces_paginated when IDs, namespaces, or prefixes contain spaces.

Testing

  • Added tests/unit/test_query_param_space_encoding_705.py covering sync/async HTTPClient, existing query strings, literal + preservation, and end-to-end Index.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 via httpx.QueryParams, then urlencode with quote/safe="") and _prepare_url_and_params, which merges that string onto the request path and drops params from kwargs so httpx does not rewrite %20 back to +. Sync and async HTTPClient verbs that accept params now go through this path; enum resolution from _prepare_params is unchanged. POST’s json-only fast path is untouched.

New unit tests in test_query_param_space_encoding_705.py assert %20 encoding, literal + as %2B, merging with an existing ?query=, and end-to-end Index / IndexAsyncio fetch/list paths.

Reviewed by Cursor Bugbot for commit e4f6ba0. Bugbot is set up for automated code reviews on this repo. Configure here.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug] Spaces in IDs and namespaces sent as "+" in GET requests since 9.0.0 (regression of #372)

1 participant