Skip to content

fix(client): allow explicit empty apiKey string#1961

Open
mralonsocorona wants to merge 1 commit into
openai:mainfrom
mralonsocorona:fix-empty-api-key-credential-check
Open

fix(client): allow explicit empty apiKey string#1961
mralonsocorona wants to merge 1 commit into
openai:mainfrom
mralonsocorona:fix-empty-api-key-credential-check

Conversation

@mralonsocorona

Copy link
Copy Markdown

Summary

Fixes a credential validation regression introduced when admin API key auth support added a missing-credentials guard.

The guard used !apiKey, which treats an explicitly provided empty string as missing. Since apiKey is typed as string | ApiKeySetter | null | undefined, this updates the check to treat only null and undefined as missing.

Fixes #1957.

Changes

  • Use apiKey == null in the missing-credentials guard.
  • Add a regression test for new OpenAI({ apiKey: "" }).

Testing

  • ./node_modules/.bin/jest tests/index.test.ts -t "apiKey empty string|at least one"
  • ./scripts/format
  • ./scripts/lint

tests/index.test.ts: 64/64 passing.

@mralonsocorona mralonsocorona requested a review from a team as a code owner June 26, 2026 00:03
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.

apiKey became mandatory in v6.36.0

1 participant