Skip to content

[codex] validate api key before login success#21983

Open
rahult-oai wants to merge 6 commits intomainfrom
codex/validate-api-key-before-login-success
Open

[codex] validate api key before login success#21983
rahult-oai wants to merge 6 commits intomainfrom
codex/validate-api-key-before-login-success

Conversation

@rahult-oai
Copy link
Copy Markdown

Summary

  • validate API-key login against the provider-owned /models path before persisting credentials
  • return an explicit login error for unusable API keys instead of reporting success immediately
  • add regression coverage for valid and invalid API-key login flows

Why

account/login/start currently accepts any API-key string, writes it to auth storage, and reports success before the key has ever been used. In desktop onboarding that lets an invalid key advance the user into the product, only to fail on the first real request.

Impact

Invalid or unusable API keys now stay on the login step and fail immediately. Valid API-key login keeps the same behavior, but only after the credential has been proven usable.

Validation

  • cargo test -p codex-app-server --test all login_account_api_key_rejects_unusable_key_before_persisting
  • cargo test -p codex-app-server --test all login_account_api_key_
  • cargo fmt --all --check
  • fresh Codex desktop onboarding run against a locally built patched CLI: sk-invalid-test-key now stays on the API-key step and surfaces API key is invalid or unusable.

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented May 9, 2026

All contributors have signed the CLA ✍️ ✅
Posted by the CLA Assistant Lite bot.

@rahult-oai
Copy link
Copy Markdown
Author

I have read the CLA Document and I hereby sign the CLA

github-actions Bot added a commit that referenced this pull request May 10, 2026
@rahult-oai
Copy link
Copy Markdown
Author

recheck

@rahult-oai rahult-oai marked this pull request as ready for review May 10, 2026 23:30
Copy link
Copy Markdown
Contributor

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

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: cf1f255a5f

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

api_key: &str,
) -> CoreResult<()> {
OpenAiModelsEndpoint::with_auth(provider_info, CodexAuth::from_api_key(api_key))
.list_models(&client_version_to_whole())
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

P1 Badge Validate API keys without requiring Codex model metadata

For a normal OpenAI API-key login, this calls the default https://api.openai.com/v1/models path but list_models deserializes the response as Codex's ModelsResponse { models } metadata schema. The public OpenAI models endpoint returns a different list shape, so valid keys fail validation with a decode/internal error before being persisted.

Useful? React with 👍 / 👎.

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.

1 participant