Skip to content

fix: stop retries from re-encoding path parameters - #298

Open
RaphaelFakhri wants to merge 1 commit into
GetStream:mainfrom
RaphaelFakhri:fix/retry-double-encodes-path-params
Open

RaphaelFakhri wants to merge 1 commit into
GetStream:mainfrom
RaphaelFakhri:fix/retry-double-encodes-path-params

Conversation

@RaphaelFakhri

Copy link
Copy Markdown

Why

build_path percent-encodes each value in the caller's path_params dict in place. The retry loop in _request_sync and _request_async passes the same kwargs, and therefore the same path_params dict, to every attempt. On the first attempt a value such as a b:c becomes a%20b%3Ac. On a retry the encoded value is encoded again and the request goes to a%2520b%253Ac, which addresses a different resource and typically returns a 404 instead of the result of the retried request.

The problem only appears when RetryConfig(enabled=True) is set, the request is a GET or HEAD, and a path parameter contains a character that quote escapes.

Changes

  • build_path quotes the values into a new dict and leaves the caller's mapping unchanged.
  • Add sync and async tests that retry a GET after a 429 and assert that both attempts request the same path.

Both new tests fail without the change (the second request uses a%2520b%253Ac) and pass with it.

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.

1 participant