Skip to content

fix: validate workload identity access tokens - #1885

Merged
HAYDEN-OAI merged 3 commits into
openai:mainfrom
pragnyanramtha:codex/validate-workload-access-token
Jun 24, 2026
Merged

HAYDEN-OAI merged 3 commits into
openai:mainfrom
pragnyanramtha:codex/validate-workload-access-token

Conversation

@pragnyanramtha

Copy link
Copy Markdown
Contributor

Summary

  • validate successful workload identity token exchange responses before caching them
  • throw an OpenAIError when a 200 response omits or returns an empty access_token
  • preserve the existing default expires_in behavior while respecting explicit 0 with nullish coalescing

Why

A malformed token exchange success response was previously trusted and cached. If access_token was absent, getToken() could return undefined, allowing downstream requests to construct an invalid bearer token instead of failing at the authentication boundary.

Validation

  • yarn test tests/auth/workload-identity-auth.test.ts --runInBand
  • yarn test tests/lib/workload-identity.test.ts --runInBand
  • ./node_modules/.bin/prettier --check src/auth/workload-identity-auth.ts tests/auth/workload-identity-auth.test.ts
  • ./node_modules/.bin/eslint src/auth/workload-identity-auth.ts tests/auth/workload-identity-auth.test.ts
  • ./scripts/build
  • git diff --check

@pragnyanramtha
pragnyanramtha marked this pull request as ready for review May 17, 2026 04:26
@pragnyanramtha
pragnyanramtha requested a review from a team as a code owner May 17, 2026 04:26
Copilot AI review requested due to automatic review settings May 17, 2026 04:26

Copilot AI 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.

Copilot encountered an error and was unable to review this pull request. You can try again by re-requesting a review.

@HAYDEN-OAI

Copy link
Copy Markdown
Contributor

@pragnyanramtha thanks again for catching this and tightening the auth boundary so malformed token responses fail cleanly. really appreciate the careful work here. merging now! 💚

@HAYDEN-OAI
HAYDEN-OAI merged commit 80febe4 into openai:main Jun 24, 2026
10 checks passed
@stainless-app stainless-app Bot mentioned this pull request Jun 24, 2026

This branch was previously deployed

1 inactive deployment
ci — 0f06be00 Deployed Jun 24, 2026 by HAYDEN-OAI via examples #4225
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.

3 participants