Skip to content
This repository was archived by the owner on May 13, 2026. It is now read-only.

feat(onboarding): validate Anthropic key on save/bootstrap before persist - #1030

Merged
shiba4life merged 2 commits into
mainfrom
feat/validate-anthropic-key-on-save
May 13, 2026
Merged

feat(onboarding): validate Anthropic key on save/bootstrap before persist#1030
shiba4life merged 2 commits into
mainfrom
feat/validate-anthropic-key-on-save

Conversation

@shiba4life

Copy link
Copy Markdown
Collaborator

Summary

  • Add crate::ingestion::anthropic::validate_key: one cheap GET to /v1/models that returns Result<(), AnthropicValidationError>Invalid on 401/403, Transient on everything else.
  • Wire it into POST /api/ingestion/config and POST /api/setup/bootstrap: 400 + structured error on bad key, no persistence; 200 + warning field on transient probe failure, key still saved.
  • Onboarding wizard's ConfigureAiStep renders the inline error inline (bounces back on 400) and shows a soft-warning banner when the probe couldn't reach Anthropic.

Closes the dogfooded silent-save bug where a typo'd Anthropic key persisted cleanly and only surfaced as a 401 the first time the user tried to ingest.

Test plan

  • Helper unit tests (wiremock): 200 / 401 / 403 / 500 / 429 / DNS failure → correct variant in each case
  • save_ingestion_config route tests: bad-key 400 + no persistence; transient 500 + soft-warn + key persisted; Ollama save doesn't probe; ***configured*** placeholder doesn't probe
  • bootstrap route tests: bad-key 400 + no identity / no marker / no key store; transient 503 + bootstrap completes + warning field + key persisted
  • ConfigureAiStep UI tests: renders apiKeyError inline when set, hides when null
  • cargo clippy --workspace --all-targets -- -D warnings (clean)
  • cargo test --workspace --all-targets (one unrelated flaky timeout in apple_consolidation_migration_test — passes in isolation)
  • npm test (2 unrelated 1s-timeout flakes under parallel load; pass in isolation)
  • bash scripts/lint-tracing-egress.sh (new probe is // trace-egress: skip-3p)

🤖 Generated with Claude Code

…sist

POST /api/ingestion/config and POST /api/setup/bootstrap now probe
Anthropic's /v1/models endpoint with the supplied key before persisting.
A definitive 401/403 returns HTTP 400 with `{error: invalid_anthropic_key,
detail: <upstream message>}` and writes nothing. Transient failures
(DNS, 5xx, timeout) attach a `warning` field to the 200 response and
still persist — refusing to save during an Anthropic outage would be
worse than the silent-save bug we're fixing.

The wizard's ConfigureAiStep now renders the inline error returned by
bootstrap (bounces back to the AI step on 400, clears on next keystroke)
and shows a soft-warning banner when the probe couldn't reach Anthropic.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@shiba4life
shiba4life enabled auto-merge May 13, 2026 04:16
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@shiba4life
shiba4life added this pull request to the merge queue May 13, 2026
Merged via the queue into main with commit 0039f87 May 13, 2026
11 checks passed
@shiba4life
shiba4life deleted the feat/validate-anthropic-key-on-save branch May 13, 2026 04:30
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant