getAnthropicModels() was called unconditionally on mount, causing a console error when no API key was set. Now chains the call after getAnthropicApiKeyExists() confirms a key is present. Includes regression test added before the fix per bug workflow. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
25 lines
869 B
Markdown
25 lines
869 B
Markdown
---
|
|
name: Anthropic models fetched without API key
|
|
---
|
|
|
|
# Bug 1: Anthropic Models Fetched Without API Key
|
|
|
|
## Symptom
|
|
|
|
Browser console shows `Error: Anthropic API key not found. Please set your API key.` on every page load, even when the user has no Anthropic API key and is using `claude-code-pty`.
|
|
|
|
## Root Cause
|
|
|
|
`Chat.tsx` unconditionally calls `api.getAnthropicModels()` on mount. The server endpoint requires an API key to call the Anthropic models list API. When no key is set, the request fails with an error logged to the console.
|
|
|
|
## Reproduction Steps
|
|
|
|
1. Start the server without setting an Anthropic API key
|
|
2. Open the web UI
|
|
3. Open browser developer console
|
|
4. Observe the error on page load
|
|
|
|
## Proposed Fix
|
|
|
|
Only call `getAnthropicModels()` after `getAnthropicApiKeyExists()` confirms a key is set. Chain the calls so the models fetch is conditional.
|