Validate Anthropic API key in api-key and provider commands in Studio Code CLI - #4504
Merged
Conversation
1 task
sejas
marked this pull request as ready for review
August 11, 2026 12:14
sejas
requested review from
bcotrim,
katinthehatsite,
nightnei and
shaunandrews
August 11, 2026 12:18
bcotrim
approved these changes
Aug 11, 2026
bcotrim
left a comment
Contributor
There was a problem hiding this comment.
Changes LGTM 👍
Changing provider doesn't clear the saved key, so we can still boot straight into a dead one — isReady() is just Boolean(anthropicApiKey) (providers.ts:211) and the auto-fallback never calls prepare. Worth validating at boot too, or is the startup round trip too costly? Fine as a follow-up either way.
Contributor
|
I've pushed an empty commit to trigger the full CI checks (E2E, Performance tests) |
Collaborator
📊 Performance Test ResultsComparing 8de6983 vs trunk app-size
site-editor
site-startup
Results are median values from multiple test runs. Legend: 🟢 Improvement (faster) | 🔴 Regression (slower) | ⚪ No change (<50ms diff) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Related issues
How AI was used in this PR
AI helped identify and build the code.
Proposed Changes
This PR validates the key at entry time, in both
/api-keyand/provider(both funnel through the provider'spreparestep), and displays an error if the key is not valid.It only affects CLI. The UI is being implemented in #4503
Testing Instructions
npm run cli:build && node apps/cli/dist/cli/main.mjs code/api-keyand enter a made-up key (e.g.fake key): the prompt shows "Anthropic rejected this API key. Check the key and try again." and stays open. Enter a real key: it saves.~/.studio/cli.jsonand corrupt the savedanthropicApiKey, then run/providerand pick "Anthropic · API key": the CLI re-prompts for a key instead of accepting the broken one./api-keywith any non-empty key — it saves (unverifiable ≠ invalid).validate-api-key-when-saving-cli.mp4
Pre-merge Checklist