Skip to content

fix: make ChatGPT/API-key auth conflicts actionable - #19

Merged
mldangelo-oai merged 7 commits into
mainfrom
mdangelo/codex/fix-chatgpt-auth-precedence-20260728
Jul 29, 2026
Merged

mldangelo-oai merged 7 commits into
mainfrom
mdangelo/codex/fix-chatgpt-auth-precedence-20260728

Conversation

@mldangelo-oai

Copy link
Copy Markdown
Collaborator

Problem

A successful ChatGPT login can be silently overridden by an ambient OPENAI_API_KEY or CODEX_API_KEY. The subsequent scan then reports a generic authentication or model-access error, and the existing recovery hint is hidden in non-interactive terminals. This makes users think that ChatGPT login is broken even though a different credential was actually selected.

Change

  • Warn immediately after successful ChatGPT or device-code login when an environment API key will take precedence.
  • Identify the exact effective environment-variable source in 401 and 403 scan failures.
  • Include the ChatGPT recovery instructions in the final failure message so they are visible in CI and other non-TTY environments.
  • Preserve existing environment-key precedence, intentional API-key login, stored-credential behavior, existing exit codes, and credential/provider-context redaction.
  • Add targeted regressions for both key variables, normal and device-code ChatGPT login, unsuccessful login, and non-interactive authentication and model-access failures.

This is intentionally limited to the P0 authentication issue: no TAC gate, policy changes, token-refresh write-back, cost changes, or unrelated documentation changes.

Verification

  • Full public-CI test suite using the pinned Bun 1.3.14: 348 passed, 3 expected platform/integration skips, 0 failed.
  • Focused authentication suite: 11 passed, 0 failed.
  • Full TypeScript typecheck and SDK/CLI production build.
  • Package-wide Prettier and generated-model checks.
  • Packed and validated the actual public npm tarball: 178 validated entries.
  • Successfully installed the packed release and verified public SDK import, executable CLI, and all 94 bundled plugin files.
  • Eight additional compiled, zero-network authentication regressions covering both keys, 401, 403, stored credentials, and device-code login.

@mldangelo-oai
mldangelo-oai marked this pull request as ready for review July 28, 2026 23:04

@chatgpt-codex-connector chatgpt-codex-connector Bot 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.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 2918e3e6ef

ℹ️ 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".

Comment thread sdk/typescript/src/cli.ts Resolved

@chatgpt-codex-connector chatgpt-codex-connector Bot 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.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: b4b9b5d079

ℹ️ 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".

Comment thread sdk/typescript/src/cli.ts Resolved
ianw-oai
ianw-oai previously approved these changes Jul 28, 2026
@daneschneider-oai

Copy link
Copy Markdown
Collaborator

Superseded by #22, which is now merged. The subprocess-level effective-API-key regression from this PR is preserved in follow-up #23, alongside the access-token login warning.

@mldangelo-oai
mldangelo-oai requested a review from ianw-oai July 29, 2026 06:09
ianw-oai
ianw-oai previously approved these changes Jul 29, 2026

@zcrab-oai zcrab-oai left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approved. I left one non-blocking inline note about the access-token login warning promising an interactive credential choice that the current ChatGPT-only status check does not provide. The access-token-specific wording in #23 already addresses the concern.

Comment thread sdk/typescript/src/cli.ts Resolved
@mldangelo-oai
mldangelo-oai merged commit a1f3821 into main Jul 29, 2026
4 checks passed
@mldangelo-oai
mldangelo-oai deleted the mdangelo/codex/fix-chatgpt-auth-precedence-20260728 branch July 29, 2026 19:34
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.

4 participants