Skip to content

fix: correct websocket_base_url derivation to preserve http in query params#3301

Open
AliSharjeell wants to merge 1 commit into
openai:mainfrom
AliSharjeell:fix/websocket-base-url-derivation
Open

fix: correct websocket_base_url derivation to preserve http in query params#3301
AliSharjeell wants to merge 1 commit into
openai:mainfrom
AliSharjeell:fix/websocket-base-url-derivation

Conversation

@AliSharjeell
Copy link
Copy Markdown

Summary

  • Converted websocket_base_url from a simple attribute to a property
  • The property now correctly derives the websocket URL from base_url by only replacing the scheme prefix
  • This fixes the bug where str.replace() was replacing ALL occurrences of http:// or https:// in the URL, including those in query parameters

Fix

When websocket_base_url is not explicitly set, it is now derived from base_url using httpx.URL's copy_with method, which only changes the scheme component rather than doing string replacement.

Test

Verified that URLs with http:// in query parameters are handled correctly.

Closes #3294

@AliSharjeell AliSharjeell requested a review from a team as a code owner May 23, 2026 07:03
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: a52297ef13

ℹ️ 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 thread src/openai/_client.py
self.webhook_secret = webhook_secret

self.websocket_base_url = websocket_base_url
self._websocket_base_url = websocket_base_url
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge Restore AsyncOpenAI.websocket_base_url attribute

Assigning only self._websocket_base_url here removes the public websocket_base_url instance attribute on AsyncOpenAI, but async websocket code still reads self.__client.websocket_base_url (for example in src/openai/resources/realtime/realtime.py and src/openai/resources/responses/responses.py). Because AsyncOpenAI has no corresponding property, those accesses now raise AttributeError at runtime for async clients, breaking realtime/response streaming flows.

Useful? React with 👍 / 👎.

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

1 participant