fix: preserve query params in realtime websocket URLs#3295
fix: preserve query params in realtime websocket URLs#3295nightcityblade wants to merge 1 commit into
Conversation
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 335c6f1d65
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
| path = base_url.path.rstrip("/") + "/realtime" | ||
| return base_url.copy_with(path=path) |
There was a problem hiding this comment.
Preserve raw path bytes when appending /realtime
_prepare_url() now builds the URL from base_url.path, but in httpx URL.path is URL-decoded; this means inputs with encoded delimiters (for example %2F in a proxy route segment) are decoded before copy_with(path=...) and can be reinterpreted as real path separators, changing the target endpoint. The previous raw_path-based construction preserved exact bytes, so this is a behavior regression for users who rely on encoded path segments in base_url/websocket_base_url.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Thanks for picking this up! , Happy to see this getting fixed.
Changes being requested
Fixes #3294.
Preserve query strings when normalizing
base_urlwith a trailing slash and when deriving Realtime WebSocket URLs, so query parameter values containinghttp://are not moved into the path or rewritten as part of thewss://URL construction.Additional context & links
Validation:
ruff check src/openai/_base_client.py src/openai/resources/realtime/realtime.py src/openai/resources/beta/realtime/realtime.py tests/test_client.pyruff format --check src/openai/_base_client.py src/openai/resources/realtime/realtime.py src/openai/resources/beta/realtime/realtime.py tests/test_client.pypytest -o addopts='' tests/test_client.py