Skip to content

fix: preserve query params in realtime websocket URLs#3295

Open
nightcityblade wants to merge 1 commit into
openai:mainfrom
nightcityblade:fix/issue-3294
Open

fix: preserve query params in realtime websocket URLs#3295
nightcityblade wants to merge 1 commit into
openai:mainfrom
nightcityblade:fix/issue-3294

Conversation

@nightcityblade
Copy link
Copy Markdown

  • I understand that this repository is auto-generated and my pull request may not be merged

Changes being requested

Fixes #3294.

Preserve query strings when normalizing base_url with a trailing slash and when deriving Realtime WebSocket URLs, so query parameter values containing http:// are not moved into the path or rewritten as part of the wss:// 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.py
  • ruff format --check src/openai/_base_client.py src/openai/resources/realtime/realtime.py src/openai/resources/beta/realtime/realtime.py tests/test_client.py
  • pytest -o addopts='' tests/test_client.py

@nightcityblade nightcityblade requested a review from a team as a code owner May 21, 2026 15:16
Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 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".

Comment on lines +413 to +414
path = base_url.path.rstrip("/") + "/realtime"
return base_url.copy_with(path=path)
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge 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 👍 / 👎.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for picking this up! , Happy to see this getting fixed.

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:- websocket_base_url derivation corrupts URLs containing http:// in query params

2 participants