Repository navigation
fix(responses): reject function-based API keys in WebSocket constructors - #2586
HAYDEN-OAI merged 7 commits into
Conversation
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 395125547e
ℹ️ 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".
HAYDEN-OAI
left a comment
There was a problem hiding this comment.
The fail-fast behavior is useful, but please preserve already-resolved function credentials before merging. I confirmed the regression described in the existing inline finding: _callApiKey() stores the token in client.apiKey and leaves _options.apiKey as a function, so the new check rejects a client that the existing WebSocket authentication path can use successfully.
Please enforce the unresolved-credential condition at the shared authentication boundary, preserving already-resolved credentials and supported provider authentication on both stable and beta surfaces. An async construction path that resolves credentials before connecting is another option. The important behavior is to prevent an unauthenticated connection without rejecting a usable resolved token.
Static review of 395125547ef1fce61aa1213bd32bf0345b4f707d; no tests run.
HAYDEN-OAI
left a comment
There was a problem hiding this comment.
Requesting changes for two issues affecting both stable and beta Responses WebSocket constructors: the new protected-member access does not compile, and the guard rejects provider clients even when their credential has already been resolved. A focused TypeScript compiler check confirmed TS2445 in both changed files; the credential regression was traced through the client and WebSocket authentication paths. No tests were run.
|
Addressed both review issues on the current head. The concrete constructors no longer access protected client options. Resolved credential validation now lives in the shared ResponsesWSBase authentication boundary, so unresolved function credentials are rejected there while a credential already resolved through _callApiKey() remains usable by both stable and beta WebSockets. Focused WebSocket tests pass (4/4), and TypeScript compilation succeeds. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: d2d038ff61
ℹ️ 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".
|
Addressed both new findings. The shared Responses WebSocket boundary now rejects only an unresolved function-backed apiKey, while clients with caller-managed Authorization headers or other non-apiKey authentication remain allowed. Added an internal client predicate for the unresolved-function state. The acceptance test now uses a mocked |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 5199e017f5
ℹ️ 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".
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: b22c606afa
ℹ️ 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".
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: d1165a9d0d
ℹ️ 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".
Preserve the invocation-local credential capture from main alongside the unresolved-key helper. Apply current formatting and regex lint rules to the existing WebSocket changes.
HAYDEN-OAI
left a comment
There was a problem hiding this comment.
Re-reviewed the current head and resolved eight discussions whose requested corrections are present. Four existing discussions remain unactioned.
I reproduced the existing custom-credential regression: an unresolved function key with a caller-provided string X-Auth-Token still throws before either stable or beta can connect (existing discussion). The new inline finding below also reproduces with the real ws transport: an empty static API key overrides explicitly supplied Basic authentication. These two compatibility regressions need correction before approval; I have not added duplicate findings for the other existing threads.
I also prepared a local merge with main at 425502d2, retaining its _callApiKey(capture) concurrency behavior and fixing current formatting/lint errors. Validation of that merged candidate: 328 focused tests pass on Node 22 and 24; lint, typecheck, build, and CJS/ESM stable/beta smoke checks on Node 22.0.0 and 24 pass. Separate loopback transport reproductions confirm both regressions on both surfaces. PushPatrol denied the fork push, so that merge is not yet on this PR and this review remains anchored to d1165a9d.
Reuse the shared credential-header classification and validate serialized credential snapshots without rereading the client key. Preserve empty-key Basic authentication, resolved-key overrides, and custom transport authentication ownership. Cover stable and beta entrypoints with loopback handshakes and focused regressions.
HAYDEN-OAI
left a comment
There was a problem hiding this comment.
Approved at 1cebb59. The published fixes address the authentication regressions and remaining snapshot concerns; the custom base-transport contract is documented and regression-tested. All open review conversations are resolved.
Validation on this commit: 468 focused tests pass on Node 22 and 24; lint, typecheck, build, and CJS/ESM smoke checks on Node 22.0.0 and 24 pass. Independent review found no remaining actionable correctness issue. GitHub CI is still running.
Castiron custom code✅ No new custom-code files detected. 45 mixed files remain; 5 existing customizations changed. Compared
40 existing customizations unchanged
A changed generated baseline means this report cannot reliably identify which handwritten lines changed. Inspect the custom-code diffDownload the exact patch produced by this run (requires repository access): gh run download 35120254287 --repo openai/openai-node \
--name castiron-custom-code-35120254287-1 --dir /tmp/castiron-custom-code-35120254287-1
git apply --stat /tmp/castiron-custom-code-35120254287-1/custom-code.patch
cat /tmp/castiron-custom-code-35120254287-1/custom-code.patchOr reproduce it from an SDK checkout containing the vendored reporter: git fetch --no-tags origin 425502d2bf2da1bdd37efda3b0fa5add96fc8a51 1cebb595926805d2cbd0db44bc5aec313470fe4d
python3 scripts/castiron/custom_code_report.py report \
--base 425502d2bf2da1bdd37efda3b0fa5add96fc8a51 \
--head 1cebb595926805d2cbd0db44bc5aec313470fe4d --fetch --require-head-hash --public \
--out /tmp/castiron-custom-code-1cebb5959268
cat /tmp/castiron-custom-code-1cebb5959268/custom-code.patchThis is the current full custom patch for mixed files, not an attribution of only the handwritten lines changed by this PR. |
Automated Release PR --- ## [7.17.0](v7.16.0...v7.17.0) (2026-09-16) ### Features * **api:** add compaction progress events ([#2749](#2749)) ([425502d](425502d)) ### Bug Fixes * **ci:** retry transient Deno download failures ([#2752](#2752)) ([e39037b](e39037b)) * preserve chat runner abort reasons ([#2607](#2607)) ([eda4d0c](eda4d0c)) * **realtime:** preserve native WebSocket error causes ([#2715](#2715)) ([58fa72a](58fa72a)) * **responses:** reject function-based API keys in WebSocket constructors ([#2586](#2586)) ([eea7618](eea7618)) * **runners:** reject unfinished turns in streaming runTools ([#2716](#2716)) ([937ed67](937ed67)) * **streaming:** emit terminal SSE events missing a trailing blank line ([#2726](#2726)) ([94d6418](94d6418)) * **zod:** omit impossible optional branch in strict schemas ([#2751](#2751)) ([2b4c2c7](2b4c2c7)) ### Chores * update lint tooling and tailor anti-slop for the SDK ([#2753](#2753)) ([21a03c2](21a03c2)) ### Documentation * **examples:** preserve split UTF-8 in raw stream consumer ([#2714](#2714)) ([f44152a](f44152a)) --- This PR was generated with [Release Please](https://github.com/googleapis/release-please). See [documentation](https://github.com/googleapis/release-please#release-please). Co-authored-by: openai-sdks[bot] <284451331+openai-sdks[bot]@users.noreply.github.com>
|
Thanks for the careful re-review and merge. I appreciate the help getting the WebSocket authentication boundary and regression coverage into shape. |
Summary
Responses WebSocket authentication is synchronous, so a client with an unresolved function-based
apiKeycannot authenticate the socket. At the same time, a function-backed client that has already run_callApiKey()has a resolved string inclient.apiKeyand should remain usable.The current fix enforces that invariant at the shared stable and beta
ResponsesWSBase._authHeaders()boundary instead of only in the concrete Node constructors:client.apiKeyis a resolved string, use it for theAuthorizationheader regardless of whether the original client option was a function;Review follow-up
This addresses both review findings on the original head:
ResponsesWSBasesubclasses.Tests
Stable and beta regression coverage verifies both states:
_callApiKey()resolves the provider, constructing the same WebSocket surface no longer fails the credential guard.Fresh code/security review is running on commit
d2d038ff615b3e693abf8e1a01aba0a2bbd9c140.