Skip to content

fix(realtime): forward client default headers to websocket connections - #3728

Open
sylvesterkaczmarek wants to merge 1 commit into
openai:mainfrom
sylvesterkaczmarek:fix/websocket-default-headers-1975
Open

fix(realtime): forward client default headers to websocket connections#3728
sylvesterkaczmarek wants to merge 1 commit into
openai:mainfrom
sylvesterkaczmarek:fix/websocket-default-headers-1975

Conversation

@sylvesterkaczmarek

Copy link
Copy Markdown

Summary

  • forward user-configured default_headers into Realtime WebSocket handshakes
  • preserve authentication header precedence, while per-call extra_headers remain the final override
  • apply the behavior to both sync/async Realtime clients and the legacy beta.realtime path
  • add regression coverage for proxy-auth headers and override precedence

Fixes #1975

Test plan

  • uv run ruff format src/openai/resources/realtime/realtime.py src/openai/resources/beta/realtime/realtime.py tests/lib/test_websocket_redirects.py
  • uv run ruff check src/openai/resources/realtime/realtime.py src/openai/resources/beta/realtime/realtime.py tests/lib/test_websocket_redirects.py
  • uv run pytest -o addopts= -q tests/lib/test_websocket_redirects.py -k default_headers
  • git diff --check

All focused verification steps passed before the branch was reduced to its single final commit.

@sylvesterkaczmarek
sylvesterkaczmarek requested a review from a team as a code owner August 25, 2026 00:16

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

Copy link
Copy Markdown

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: 45d6f6ff83

ℹ️ About Codex in GitHub

Your team has set up Codex to 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 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines +718 to 719
**self.__client._custom_headers,
**auth_headers,

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 Merge authentication headers case-insensitively

When a caller supplies a differently cased authentication key such as default_headers={"authorization": "Bearer stale"}, this case-sensitive dictionary expansion retains both that value and the generated Authorization header. WebSocket header names are case-insensitive, so the handshake receives duplicate credentials rather than the intended generated-auth precedence and may be rejected; the same pattern occurs in the sync and beta paths. Normalize header names or remove case-insensitive collisions before connecting, and cover this case in both sync and async authentication tests.

AGENTS.md reference: AGENTS.md:L41-L45

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.

extra_headers while using as proxy

1 participant