fix(realtime): forward client default headers to websocket connections - #3728
fix(realtime): forward client default headers to websocket connections#3728sylvesterkaczmarek 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: 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".
| **self.__client._custom_headers, | ||
| **auth_headers, |
There was a problem hiding this comment.
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 👍 / 👎.
Summary
default_headersinto Realtime WebSocket handshakesextra_headersremain the final overridebeta.realtimepathFixes #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.pyuv run ruff check src/openai/resources/realtime/realtime.py src/openai/resources/beta/realtime/realtime.py tests/lib/test_websocket_redirects.pyuv run pytest -o addopts= -q tests/lib/test_websocket_redirects.py -k default_headersgit diff --checkAll focused verification steps passed before the branch was reduced to its single final commit.