Repository navigation
fix: preserve workload identity authorization overrides - #2689
HAYDEN-OAI wants to merge 154 commits into
Conversation
Castiron custom code✅ No new custom-code files detected. 32 mixed files remain; 1 existing customization changed. Compared
31 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 34244420181 --repo openai/openai-node \
--name castiron-custom-code-34244420181-1 --dir /tmp/castiron-custom-code-34244420181-1
git apply --stat /tmp/castiron-custom-code-34244420181-1/custom-code.patch
cat /tmp/castiron-custom-code-34244420181-1/custom-code.patchOr reproduce it from an SDK checkout containing the vendored reporter: git fetch --no-tags origin f65d190316d34974d4643f7d43187271d7c539f6 a1fb5888aaa28fa69abe83bc813826f3354ded1f
python3 scripts/castiron/custom_code_report.py report \
--base f65d190316d34974d4643f7d43187271d7c539f6 \
--head a1fb5888aaa28fa69abe83bc813826f3354ded1f --fetch --require-head-hash --public \
--out /tmp/castiron-custom-code-a1fb5888aaa2
cat /tmp/castiron-custom-code-a1fb5888aaa2/custom-code.patchThis is the current full custom patch for mixed files, not an attribution of only the handwritten lines changed by this PR. |
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
Security findingsAdvisory findings (5)
ℹ️ 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: 65c4fad66e
ℹ️ 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: 89f68f9261
ℹ️ 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".
markstuart-oai
left a comment
There was a problem hiding this comment.
Reviewed all three files in the actual merge-base diff, the header/authentication/retry contracts, and the prior bot findings and author responses at b2e3e84. The ordinary override and wrapped-hook cases now pass, but one P2 compatibility issue remains: provenance still depends on identities that supported hooks can replace. Please fix the ownership of that state rather than adding another clone-specific propagation branch.
Independent validation: all 44 workload-identity tests pass; the broader auth/X.509 selection has 1,253 passing tests and 19 loopback-HTTP failures in this VM (including proxy 403 errors). Build/CJS and ESM import checks, lint, and diff whitespace checks pass using reused dependencies. Full type checking is blocked by missing example dependencies. A standalone public-client probe succeeds on actual base c581c17 and reproduces the inline finding on this head, including Node 22.0.0 and 26.7.0. No file crosses the 1,000-line threshold; client.ts was already above it. Full/generated suites and the complete runtime matrix were not independently rerun.
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: b2e3e84970
ℹ️ 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: 2ee9d4a935
ℹ️ 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".
markstuart-oai
left a comment
There was a problem hiding this comment.
Re-reviewed 2ee9d4a against actual base c581c17 and my previous reviewed head b2e3e84, including all three changed files and new discussion. The buildRequest header-copy variant from review 5134684699 is fixed. The derived-options variant acknowledged in response 3952077575 remains reproducible, and the new refreshability heuristic introduces a separate inherited-iterator regression; both are detailed inline. The structural issue remains: copying token markers across more hook layers and guessing iterator replayability adds branches without establishing stable ownership at the authentication/header boundary.
Independent validation: 382 workload-identity/expiration/X.509 tests pass (including all 47 workload-identity client tests); build with CJS/ESM import checks, lint, and whitespace checks pass using the existing dependency tree. Standalone public-client probes reproduce both inline findings on Node 22.0.0 and 22.23.2, with passing base controls. I also corroborated the already-reported post-dispatch header-mutation issue in discussion 3952068567. Full/generated suites, full type checking, and the complete runtime matrix were not rerun; the prior example-dependency and VM loopback limitations remain. No file crosses 1,000 lines (client.ts was already over; its current size is 2,471 lines).
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 1b170b23ca
ℹ️ 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".
markstuart-oai
left a comment
There was a problem hiding this comment.
Re-reviewed 1b170b2 following the new follow-up, including the full three-file PR diff, the delta from 2ee9d4a, and new author responses. I independently verified the copied-options/final-header cases and post-dispatch mutation case are fixed, consistent with responses 3952153163 and 3952153286. Removing the Headers-marker propagation is a useful simplification. Two boundary problems remain in the new ownership model, detailed inline: it requires mutable caller options and treats input to an opaque dispatch hook as evidence of the credential actually sent.
The inherited one-shot iterator finding from review 5134731505 also remains reproducible: the custom header is preserved on c581c17/b2e3e849 and dropped on this head. Please address #2689 (comment) at the canonical header boundary.
Structural blocker: tests/lib/workload-identity.test.ts grows from 457 lines at the merge-base to 1,016 (885 at the previous reviewed head). This pushes the file past 1k lines. Can we decompose this first? Move the cohesive copied-hook/dispatch-provenance regression suite into a focused test module and share the repeated synthetic token/transport fixture without introducing a generic test framework.
Validation: 393 selected workload-identity/expiration/X.509 tests pass, including all 58 public workload tests. Build with CJS/ESM import checks, lint, and whitespace checks pass using reused dependencies. Independent public-entrypoint probes ran on Node 22.0.0 and 22.23.2 against this head and relevant prior/base controls. Full/generated suites, full type checking, and the complete runtime matrix were not rerun.
markstuart-oai
left a comment
There was a problem hiding this comment.
Re-reviewed the full three-file PR diff and the delta from R3 (1b170b2), including the additional test-only commit after assigned head 34e4b26. This review covers current head 5f49b92. Plain frozen/sealed/non-extensible options now work; copied mutable options and post-dispatch mutation still pass. However, combining non-extensible options with a copied auth-hook delegation loses provenance, as detailed inline. The extra alias map retains the original identity dependency instead of giving both paths one stable owner.
Two prior P2 findings remain independently reproducible on this head: the inherited one-shot iterator drops its custom header (discussion 3952116322), and a dispatch-owning hook that sends independent credentials still causes two workload exchanges/two API attempts with maxRetries: 0 (discussion 3952160306). Please retain those fixes in scope.
The structural decomposition request is also unresolved: tests/lib/workload-identity.test.ts is now 1,122 lines, versus 457 at the merge-base. This pushes the file past 1k lines. Can we decompose this first? Extract the cohesive hook/provenance suite and share its repeated synthetic transport fixture instead of continuing to append cases to the general workload-identity suite.
Validation: all 399 selected workload/expiration/X.509 tests pass, including 64 public workload tests. Build/CJS and ESM import checks, lint, and whitespace checks pass using reused dependencies. Independent probes ran on Node 22.0.0 and 22.23.2, with actual-base and prior-head controls. Full/generated suites, full type checking, and the complete runtime matrix were not rerun.
markstuart-oai
left a comment
There was a problem hiding this comment.
Re-reviewed all seven current changed files, the full PR diff, the delta since 5f49b92, and the additional 97f3ea8 → 1c25b81 changes found during the final refresh. The immutable-options/copied-hook case from #discussion_r3952185461 now passes independently for freeze, seal, and preventExtensions. The inherited one-shot header snapshot, delegated post-dispatch mutation, and nondelegating transport ownership cases also pass. Moving snapshots into the canonical header boundary and splitting the tests (593/531/144 lines plus a 39-line fixture) resolve the earlier decomposition concerns.
One P2 remains in the new fix: broadcasting issued-token provenance to every active request scope loses request ownership under concurrency and can replay a separately supplied credential. Please keep this ownership request-local instead of adding a client-wide fallback; details and a reproduced case are inline.
Validation on this exact head: build, lint, diff whitespace check, and 412 tests across nine workload/X.509 suites passed on Node 24.20.0. Independent synthetic probes also covered hardened/copied options and concurrent ownership on Node 22.0.0. The separate eight loopback header-compatibility tests attempted earlier in this pass were blocked by the VM proxy returning 403; no full generated/integration suite or full runtime matrix is claimed.
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 1c25b81fc2
ℹ️ 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: af703d8620
ℹ️ 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 Security Review
Here are some automated security review suggestions for this pull request.
Reviewed commit: ed25b283ed
ℹ️ About Codex security reviews in GitHub
This is an experimental Codex feature. Security reviews are triggered when:
- You comment "@codex security review"
- A regular code review gets triggered (for example, "@codex review" or when a PR is opened), and you’re opted in so security review runs alongside code review
Once complete, Codex will leave suggestions, or a comment if no findings are found.
markstuart-oai
left a comment
There was a problem hiding this comment.
R53 at 721f9ce: the remaining request-field presence P2 is fixed. Enumerable self-removing body/headers getters through delegating timeout hooks are read once with their original receiver; both explicit undefined keys reach configured fetch and suppress its defaults. Node 22/24 controls agree with the preserved baseline. Null, absent, inherited/non-enumerable values, transparent Proxy, throwing getter and streaming-body controls were also checked.
The direct rest snapshot establishes presence and value together. The two-field fallback preserves the PR's inherited/non-enumerable compatibility without rereading captured enumerable accessors. This remains local to request normalization, removes the conditional reconstruction spreads, and does not introduce another ownership helper. client.ts grows 3,178→3,193 lines; protocol/replay remain 183/919, with no new 1k crossing. I found no structural blocker in this repair.
[P2] I independently verified the existing nested iterator report 3957619114. Start with an array-valued lowercase Authorization alias and a self-removing uppercase workload placeholder; while token acquisition is pending, replace the nested array's Symbol.iterator with one yielding an independent bearer. R52 and R53 dispatch the workload bearer; the baseline dispatches the independent bearer on Node 22/24. Ordinary nested-slot replacement remains correct. Null-only variants are baseline-equivalent and excluded. Revalidate the nested array's protocol through the canonical descriptor/protocol model before retaining its old iterator/slot replay; invalidate an observed replacement while preserving unchanged/self-removing one-shot reads. This is newly verified existing behavior, not a regression introduced by this two-file patch. No duplicate inline added.
Fresh validation: production build/CJS+ESM import checks and lint pass; eight focused suites pass on Node 24 (146 tests), with Node 22.0.0 reporting 123 pass/23 skip. Independent old/current/baseline probes cover presence and the nested report; All 16 request-shape cases produce matching transport results across Node 22/24; read-order differences were checked against baseline. Deferred-acquisition/network-timeout, outer iterable replacement and opaque-transport controls remain intact. All 64 PR files are accounted for: two changed files freshly inspected, 62 verified byte-identical with prior review retained. Baseline build and prior broad runtime/package evidence were reused, not rebuilt/rerun.
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 721f9cee18
ℹ️ 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".
markstuart-oai
left a comment
There was a problem hiding this comment.
R54 at 99b9fa4 materially repairs the single-layer cases in 3957619114. Request-only and default-only nested iterator replacements now send the independent bearer and retain it through a 500 retry. Inherited/getter/self-removing iterator controls pass with one replacement-factory call and the correct receiver, including an overridden .call.
[P2] The same issue remains when defaultHeaders and request headers reference the same record. Use the reported lowercase array-valued alias plus self-removing uppercase placeholder, then replace the nested iterator during acquisition with a factory returning one shared cursor containing the independent bearer. The two layer reads exhaust that cursor; the request layer's retained placeholder then wins. R53 and R54 send the workload bearer even on a single successful POST, while the baseline sends the independent bearer. Node 22/24 agree; a fresh cursor per factory invocation passes. Preserve the shared one-shot observation/independent credential through both layers, or otherwise prevent the exhausted replacement from reviving the retained workload placeholder. This is a narrower remaining case in the existing thread, not a duplicate inline or a claimed new regression from this patch. Baseline later-retry behavior is not being presented as correct.
Structurally, the canonical protocol owner replaces the nested retained-iterator field rather than adding a parallel descriptor model. The completed-observation flag has a distinct role from reusable slot state. Replay grows 919→934 lines; protocol remains 183 and client 3,193. No new structural blocker or 1k crossing found. The accessor-presence and network-timeout repairs remain intact.
Fresh validation: build/CJS+ESM import checks and lint pass; Node 24 has 1,241 passing workload tests across 48 suites; exact Node 22.0.0 has 264 pass/2 skip across six focused suites. Independent old/current/baseline probes cover the repaired and remaining cases, receiver handling, ordinary-slot/null controls, lifecycle, presence, timeout and opaque transport. All 64 files are accounted for: three changed files freshly inspected, 61 verified byte-identical with prior review retained. Baseline build and broader package/runtime evidence were reused, not rebuilt/rerun.
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 99b9fa4352
ℹ️ 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".
| if (current.state === 'unknown') { | ||
| return true; | ||
| } |
There was a problem hiding this comment.
Invalidate cached credentials when descriptor evidence disappears
When an array header source is a Proxy whose slot initially yields the workload placeholder, but whose getOwnPropertyDescriptor trap becomes unavailable while token acquisition is pending and whose live slot now yields Authorization: null or an independent bearer, this branch treats the unknown probe as proof that the old slot is unchanged. iterateHeaderArray consequently replays the cached placeholder instead of reading the live override, so the SDK resolves and dispatches the workload token—potentially to an absolute caller-selected URL—where the parent revision would read the post-acquisition value. Fail closed or invalidate authorization-bearing slot snapshots when their current descriptor cannot be verified.
AGENTS.md reference: AGENTS.md:L98-L105
Useful? React with 👍 / 👎.
|
Codex Review: Something went wrong. Try again later by commenting “@codex review”. ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
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". |
1 similar comment
|
Codex Review: Something went wrong. Try again later by commenting “@codex review”. ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
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". |
markstuart-oai
left a comment
There was a problem hiding this comment.
R55 at ff123bc fixes the shared-layer case in 3957619114. A single replacement cursor now preserves the independent bearer on the first successful POST and through 401/500 controls, including aliased default/request layers. Node 22/24, inherited/getter/self-removing descriptors, fresh-cursor and single-layer controls were checked; the old baseline is credited only for its first-dispatch control, not later retry correctness.
One new P2 is inline: an intervening nonempty property/source replacement does not invalidate this layer's eligibility for an older cursor observation. Restoring the original exhausted source reintroduces its old header value, unlike R54 and baseline. The remove-and-restore control already passes.
The new owner has an earned boundary—completed canonical cursor values shared across related layers—distinct from per-layer protocol/slot state. The missing replacement invalidation should be fixed there without evicting observations still valid for sibling layers. Replay grows 934→955 lines; the new owner is 59, protocol remains 183, and client remains 3,193. No new 1k crossing or separate structural finding.
Fresh validation: build/CJS+ESM import checks and lint pass; Node 24: 1,250 workload tests across 48 suites; exact Node 22.0.0: 268 pass/2 skip across six focused suites. Independent current/R54/baseline probes verify the repair and new regression. Presence, timeout and opaque-transport controls remain intact. All 65 PR files are accounted for: three changed/new files freshly inspected, 62 verified byte-identical with prior review retained. Baseline build and broader package/runtime evidence were reused, not rebuilt/rerun. Previously accepted opaque-descriptor and retained-tee cancellation boundaries are unchanged.
| } | ||
| const observed = this.observations.get(iteration)?.get(name); | ||
| const reused = !!( | ||
| history?.get(name)?.value !== undefined && |
There was a problem hiding this comment.
[P2] Invalidate this layer's old observation after a property replacement
A non-undefined history value does not establish that this layer still owns the original observation. With two one-shot arrays first and second, send {'X-Probe': first}, replace the property with second after the first 500, then restore first after the second 500. This guard reuses the exhausted first cursor's cached entry: R55 sends first, second, first, while R54 and baseline send first, second, absent on Node 22/24. Replacing the property with an accessor returning second and restoring its original descriptor has the same result. The deletion/reinsertion test passes because history becomes undefined, but replacement leaves it populated.
Invalidate this layer's reuse eligibility when it observes a different property/source, and require that eligibility before reviving an old cursor entry. Keep the shared completed observation available to sibling layers that still legitimately own it; clearing the shared cache indiscriminately would undo the aliased-layer fix. Please add the nonempty replacement-and-restoration control alongside the removal test.
markstuart-oai
left a comment
There was a problem hiding this comment.
R56 at bd3d493 materially changes the transport/replay contract. Observable configured-fetch Authorization mutations now suppress workload refresh, including post-send cleanup, while private copies remain outside observation. The check uses the selected dispatch credential and avoids invoking a newly installed headers accessor. Same-byte updates retain refresh. The new fail-closed rule for lost Authorization descriptor evidence preserves read-once behavior and leaves already-opaque/non-auth controls intact. Live enumerable aliases now take precedence as documented. Duplicate-position changes deliberately reread displaced occurrences; unchanged positions retain their values. These are credited contract adjustments, not claims that every previous baseline behaved this way.
Two P2s remain:
- 3958368199 is unchanged: first → nonempty second → restored exhausted first still emits
first, second, first; R54/baseline emitfirst, second, absent. Both data and accessor replacements reproduce on Node 22/24; deletion/reinsertion passes. The prior shared-layer single-cursor first-POST repair remains intact. - One new inline covers incomplete cancellation classification: a custom clone can tee its source but return an unrelated response. Distinct body identities do not prove that returned body is shared; its cleanup is currently detached and errors swallowed. Ordinary unshared cleanup and genuine helper-observed retained tees otherwise pass.
Structurally, the extracted occurrence module owns one coherent identity/position invalidation calculation used by outer and nested arrays; immutable completed positions remain layer-local across forks. Descriptor evidence stays canonical, and the passive provenance option is narrowly scoped. Replay shrinks 955→900 lines; occurrence module is 118, protocol 183→185, iterator owner stays 59, client 3193→3245. No new under-to-over-1k crossing or separate structural quota finding. Cancellation sharing needs actual branch ownership rather than an identity heuristic.
Fresh checks: canonical build/CJS+ESM import checks and lint pass; Node 24 has 1,296 passing tests/51 suites, exact Node 22.0.0 has 237 pass/2 skip across seven focused suites. Independent public-entrypoint probes covered the remaining replay issue, configured-fetch mutations, descriptor loss versus initial opacity, duplicate movement, shared-cursor first dispatch, response clone/cancellation controls, presence, timeout and opaque transport. The cancellation edge was compared with preserved baseline on Node 22/24. Native caller-owned clones remain outside automatic helper attribution; no claim is made that unread retained native tee branches are automatically cleaned up.
All 69 current PR files are accounted for: 14 changed/new files inspected, 55 Git-blob-identical files retain prior review. Baseline builds and broader package/browser/runtime matrices were reused, not rerun. Existing accepted same-byte native Headers, explicit cloneResponse and restricted unowned sparse-build boundaries remain credited.
| if (body && sourceBody && copyBody && sourceBody !== body && copyBody !== sourceBody && copyBody !== body) { | ||
| // The helper observed a tee. Either branch may be retained after request tracking is released. | ||
| sharedResponseBodies.add(sourceBody); | ||
| sharedResponseBodies.add(copyBody); |
There was a problem hiding this comment.
[P2] Prove the returned body belongs to the observed tee before detaching cleanup
These three distinct identities establish that the source body changed, but not that copyBody is its other branch. A supported custom response.clone can call Response.prototype.clone.call(response) and retain that native copy, then return a separate Response with its own transport stream. this.cloneResponse(response) marks that unrelated returned stream as shared here. On an ordinary 500 retry, the next fetch starts before its async cancellation completes; if cancellation rejects, the error is swallowed. I reproduced both through client.get() on Node 22/24: R56 retries with cleanup unfinished (and succeeds despite unrelated cleanup failed), while baseline waits and propagates the failure. The existing unrelated-clone test misses this because its custom clone does not also change the source body.
Record branch sharing at the boundary that actually creates the native tee, rather than inferring the returned body's relationship from inequality. Treat arbitrary custom-clone results as unverified for this cancellation exemption unless their branch ownership is explicitly established. Add a custom clone that tees the source but returns an unrelated delayed/rejecting stream; genuine helper-created retained siblings should still avoid deadlock.
markstuart-oai
left a comment
There was a problem hiding this comment.
R57 at 19fd16a fixes 3958368199. Data/accessor replacement and restoration now produce first, second, absent, absent on Node 22/24, matching the preserved baseline; exact R56 production produces first, second, first, first. Removal, visibility, scalar/null/empty/undefined replacements also stop reviving the old cursor. An unaffected sibling retains its completed value. The shared default/request single-cursor independent bearer still survives first successful POST and 401/500 controls; baseline is credited only for that first-dispatch comparison.
The new ownership boundary is justified: the shared WeakMap stores completed cursor values, while the forked property map records each layer's continuous eligibility to reuse them. Identity changes on observed replacement and survives legitimate sibling forks; completion/pruning do not evict another layer's value. The prior property-value history alone could not distinguish replacement followed by restoration. Replay grows 900→907 lines and the owner 59→96; occurrence/protocol/client remain 118/185/3245. No new 1k crossing or separate structural finding.
The remaining P2 is 3958792709: a custom clone can tee its source but return an unrelated response whose cleanup is incorrectly detached. Response code is byte-identical to R56, and the focused current-build probe reconfirms unfinished cleanup/errors swallowed. No duplicate inline.
Fresh validation: build/import checks and lint pass; Node 24: 1,299 tests/51 suites; exact Node 22.0.0: 278 pass/2 skip across six focused suites. Independent public-entrypoint restoration, sibling and shared-cursor controls passed, plus 13 direct ownership checks and 30 unchanged R56/current lifecycle comparisons including partial/throwing iteration. R56 differential controls used its exact two changed production sources transpiled against otherwise byte-identical production. Baseline builds and broader package/runtime evidence were reused, not rerun. All 69 PR files are accounted for: four changed files inspected, 65 verified byte-identical with retained review. R56's documented transport, descriptor-loss, live-alias and duplicate-position boundaries remain credited.
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 19fd16affa
ℹ️ 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".
| const property = | ||
| previous && | ||
| previous.source === source && | ||
| sameHeaderProperty(descriptor, previous.descriptor) && | ||
| descriptor.enumerable === previous.descriptor.enumerable | ||
| ? previous | ||
| : { source, descriptor, identity: {} }; |
There was a problem hiding this comment.
Share replacement identity across sibling replay forks
When defaultHeaders and request headers reference the same record, replacing an array-valued Authorization property between retries with another single-use iterable makes the default fork consume the replacement, but this line creates a different identity when the request fork observes that same replacement, so it misses the shared observation and permanently caches the exhausted result. If a protected hook later replaces only the client's default-header layer, the still-live request-level independent bearer disappears and the next retry can upgrade to the workload token, unlike the base revision's live reread. Coordinate replacement-property identities across sibling forks so both layers retain the same completed cursor value.
AGENTS.md reference: AGENTS.md:L134-L137
Useful? React with 👍 / 👎.
markstuart-oai
left a comment
There was a problem hiding this comment.
R58 at 8f503f8 fixes 3958792709. A custom clone that tees its source but returns an unrelated response now waits for that response's cleanup and propagates rejection on Node 22/24, matching preserved baseline. Captured-global helper tees still avoid retained-sibling deadlock. Bound/custom clones work when their hooks release siblings; the new foreign-clone control verifies that explicit boundary. A custom wrapper returning an already helper-established shared body also works. Clone getters are read once with the correct receiver; bodyless and clone-error controls retain their expected retry behavior.
The direct function-identity boundary is simpler and better founded than the removed body-inequality heuristic. It adds no new abstraction or sharing registry. Client grows 3245→3252 lines; replay/iterator/protocol/occurrence modules remain 907/96/185/118. No new 1k crossing or structural finding in this delta.
One newly evaluated existing P2 remains: 3959023165. Independent public POST probes confirm that aliased default/request records observe a replacement one-shot Authorization array with different layer identities. After a later prepareOptions hook replaces only defaultHeaders, the surviving request layer loses the replacement bearer: sends are first, second, workload, versus first, second, second with R56's header implementation. Data and accessor replacements reproduce on Node 22/24; fresh-cursor and single-request-layer controls pass. Coordinate the identity of the same replacement observed by sibling forks while retaining per-layer invalidation for genuine replacement/restoration; do not remove the generation check that fixed stale-source replay.
Important limit: I did not reproduce the external report's claim that the old baseline handles this one-shot shape correctly. Baseline loses it earlier. This is a verified regression against R56's header behavior and the current layer-ownership contract, not a claimed previously working baseline case. R57's separate stale-source restoration repair remains verified, as do unaffected-sibling and shared-cursor first-dispatch controls. No duplicate inline.
Fresh validation: build/core+provider CJS/ESM import checks and lint pass; Node 24: 1,302 tests/51 suites; exact Node 22.0.0: 197 pass/7 skip across six focused suites. Independent cancellation, clone-boundary, replacement/restoration and sibling controls ran on Node 22/24. R56 comparison used its exact two header-owner sources transpiled against unchanged relevant production. All 69 PR files are accounted for: three changed files inspected, 66 Git-blob-identical files retain prior coverage, with the reported header owner re-traced. Preserved baseline builds and broader package/runtime matrices were reused, not rebuilt/rerun. Previously accepted transport, descriptor-loss, live-alias, duplicate-position, presence/timeout and sparse-input boundaries remain credited.
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 8f503f8ea5
ℹ️ 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".
markstuart-oai
left a comment
There was a problem hiding this comment.
R59 at 73ce586 fixes 3959023165. Independent POST probes on Node 22/24 now retain a shared replacement bearer after only defaultHeaders changes: first, second, second, with no workload acquisition, for both data and accessor replacements. R58 sent first, second, workload. Fresh-cursor, single-layer and X-Probe controls pass. The old baseline-parity claim remains unverified: baseline loses this one-shot shape earlier; this approval does not relabel it as a baseline repair.
The predecessor identity is an earned part of the ownership model: siblings can share the same transition from a common generation, while replacement/removal/restoration still invalidates the affected layer. Successive transitions and untouched-sibling controls pass; 3958368199 stays fixed (first, second, absent, absent). The equality helper removes duplicated source/descriptor/enumerability checks. Owner size is 96→107 lines; replay/protocol/occurrence/client stay 907/185/118/3252. No new structural blocker or 1k crossing.
3958792709 remains fixed: unrelated custom-clone cleanup waits and propagates errors; captured-global helper tees retain their documented cleanup behavior. I also evaluated 3959206032: starting cancellation of a helper-created sibling does not remove established sharing under the accepted contract. Additional tracking of caller/native cancellation liveness is not promised; this is not a new regression in the unchanged response code.
Fresh validation: build/core+provider CJS/ESM import checks and lint pass; Node 24: 1,304 tests/51 suites; exact Node 22.0.0: 282 pass/3 skip across six focused suites. Independent public-entrypoint and 14 direct transition checks cover the repair, restoration, sibling isolation and retained shared-cursor first POST/401/500 behavior. All 69 PR files are accounted for: three changed files inspected, 66 Git-blob-identical files retain prior review, with affected callers re-traced. Preserved baseline/R56 controls and broader package/runtime matrices were reused, not rebuilt/rerun. No remaining substantiated correctness or strict structural findings within the documented boundaries.
markstuart-oai
left a comment
There was a problem hiding this comment.
R60 at a1fb588 satisfies the newly expanded cleanup contract. Independent public requests on Node 22/24 verify source/copy and nested tee groups for ordinary 500 and workload 401: once all siblings are verifiably closed, the selected cancellation waits for delayed transport teardown and propagates the exact rejection. Sixteen combinations per runtime passed without observed unhandled rejections. Open, locked and released-reader siblings remain nonblocking and retain their unread bytes and reader ownership.
This is a voluntary extension beyond R59's documented established-sharing policy, not a retrospective regression or withdrawal of that approval. It addresses the new guarantee associated with 3959206032 and author response 3959495989. R59's exact client implementation still demonstrates the prior detached behavior in the comparison.
The cleanup module has a coherent responsibility: track current native-tee leaves and decide whether cancellation can safely be awaited. Weak references avoid retaining caller bodies; unavailable/collected references conservatively prevent a closed-sibling conclusion. Native closed-promise probes release their reader synchronously, read no bytes, and run independently in parallel. The group model handles nested tees without global credential state or method instrumentation. The selectedProperty capture retains the same header ownership semantics. Client shrinks 3252→3240, cleanup owner is 125 lines, header owner 107→108; replay stays 907. No new 1k crossing, unjustified wrapper/state layer, or concrete structural blocker found.
R59 sibling-replacement, R57 stale-source restoration/shared-cursor, and R58 unrelated custom-clone cleanup controls remain intact. The captured-platform and custom/bound/foreign release boundaries are unchanged.
Fresh checks: build/core+provider CJS/ESM imports and lint pass; Node 24: 1,328 tests/51 suites; exact Node 22.0.0: 223 pass/7 skip across six focused suites. Additional independent owner checks covered import-time WeakRef absence (restored afterward for platform execution) and an actually collected reference under --expose-gc. These are owner-level fallback checks, not a complete GC/runtime matrix. All 70 PR files are accounted for: five changed/new files inspected, 65 Git-blob-identical files retain prior coverage, with relevant callers re-traced. The R59 differential used its exact client source transpiled against unchanged relevant support code. Baseline and broader package/browser/runtime artifacts were reused, not rebuilt/rerun. No remaining substantiated correctness or strict structural findings within the documented boundaries.
|
Superseded by #2699, which applies the focused Authorization override fix with 12 regression cases in the existing suite. Closing this broader iteration in favor of that replacement. Credential-acquisition timing, 401 retry attribution, and hook/header ownership changes can be evaluated separately. |
Preserve explicit null and empty `Authorization` overrides from client defaults and request headers by resolving only the SDK workload-identity placeholder at dispatch. Supersedes openai#2689 with a one-line production fix and 12 focused cases in the existing workload-identity suite. The cases cover client/request overrides, case-insensitive precedence, replacement credentials, undefined values, native Headers, and placeholder resolution. Each case makes two requests to check the result with a populated credential cache. ### Review scope The acceptance criterion is that dispatch respects the final merged Authorization value, including explicit suppression. Credential-acquisition timing, 401 retry attribution, and transparent ownership through custom hooks/header copies should be evaluated as separate changes. ### Validation - `./scripts/test tests/lib/workload-identity.test.ts tests/buildHeaders.test.ts`: 46 tests passed on Node 24.20.0 and exact minimum Node 22.0.0. - `pnpm lint` and `pnpm exec tsc` passed with pnpm 11.5.1. - `pnpm build` passed, including CJS/ESM core and provider import checks. - Built CJS and ESM core imports also passed on Node 22.0.0. Validation used synthetic credentials and in-memory fetch responses.
Subject-token workload identity skips credential acquisition when default or request Authorization headers remove, empty, or replace the SDK credential. Workload 401 invalidation is tied to request-owned credential provenance and the actual SDK dispatch boundary; independent-credential POSTs are not replayed, including with maxRetries: 0.
Provenance belongs to SDK-produced authentication and request results, not a client-wide token ledger or another request's headers. Canonical independent header layers, observed Authorization mutations, and observed mismatches revoke the selected credential even when token bytes are equal. Parsed sibling copies have independent mutation state, so changing an unused scratch copy does not revoke the untouched request. Actual parsed
valuesare authoritative over stale authentication-result metadata, including accessor-backed replacements.Header materialization preserves one-shot removals through body encoding and delegating hooks. Stateful record properties, nested/coercion values, outer array slots, and repeated tuple occurrences retain their own serialized values while ordinary sibling fields remain live. Parsing preserves native getter receiver/order and lazy row validation. Aliased default/request layers share only their initial materialization, and retain independent replacement/retry state. Canonical synchronous reads register ownership immediately, including deferred materialization; concurrent requests never borrow each other's snapshots.
Preparation and custom build/authentication hooks keep first access to their original inputs. Default/request replacement during credential acquisition is retained. Dispatch bookkeeping survives legacy request copies and controller replacement through a secret-free carrier, strips that carrier before configured fetch, and releases all request bindings in finally cleanup. Native/foreign Request access bypasses caller-shadowed tag, headers, and get accessors. Local native Headers and ordinary replayable records/arrays retain transport identity; unverified/foreign iterable collections are materialized so credential validation and dispatch use the same serialized headers.
Documented compatibility boundaries:
Validation on
6b291125ca9c72ee6a45cd8582077021f0bde45c:Symphony-Work-Item: work_item:github:openai:openai-node:2689