Skip to content

fix(accounts): flag malformed API keys before connect - #25978

Merged
teamleaderleo merged 9 commits into
feat-cmux-nextfrom
lane/ux-credentials-api
Oct 29, 2026
Merged

teamleaderleo merged 9 commits into
feat-cmux-nextfrom
lane/ux-credentials-api

Conversation

@teamleaderleo

@teamleaderleo teamleaderleo commented Oct 27, 2026 •

Copy link
Copy Markdown
Collaborator

Problem

API-key detection treated any non-empty environment value as ready. A truncated, whitespace, or control-character value survived onboarding until the first Connect or prompt failed.

Change

Validate environment key shape during provider detection and report malformed values as unknown, so Accounts can direct the person to replace the key before starting a chat. The resolver remains authoritative and still rejects invalid secrets.

Validation

Added provider detection regression coverage for empty, short, and newline-containing values. Swift tests/build run through the project’s macOS CI path.

Before/after: Accounts now shows Unknown for malformed environment credentials instead of Signed in/Key found.

No capture: this changes credential checks only (Settings > Accounts status and Save validation), with no layout or style change.

No capture: the change only picks which existing Accounts status label shows for a malformed environment API key (Unknown instead of Signed in/Key found); it draws no new UI, and the capture scenes run with no provider keys in the environment, so that state cannot be shown there. ProviderDetectionSourcesTests and AccountsActionOutcomeTests cover it.

@github-actions github-actions Bot added the risk:normal Risk tier (docs/ci/risk-tiers.md) label Oct 27, 2026
@teamleaderleo

Copy link
Copy Markdown
Collaborator Author

Bead cx-947sg created for this PR by the cmux coordinator.

@github-actions

github-actions Bot commented Oct 27, 2026 •

Copy link
Copy Markdown
Contributor

cmux status (one comment, edited in place; each line is updated by the job that owns it)

Review ba02d0a: HQ feed card · gallery before/after runs · checks

App of this head (app.zip, kept 1 day)

gh workflow run reload-build.yml -R manaflow-ai/cmux --ref feat-cmux-next -f tag=pr25978 -f ref=lane/ux-credentials-api -f platform=macos -f backend_mode=local

red: cmux-next checks (god files, concurrency, crash safety, l10n); base red: the same failure on the base 400cb08; does not block

@blacksmith-sh

blacksmith-sh Bot commented Oct 27, 2026 •

Copy link
Copy Markdown

Found 6 test failures on Blacksmith runners:

Failures

Test View Logs
/tmp/tmpb4wvap0c/summary-missing.json (live):/summary-missing.json (live): View Logs
/tmp/tmpuf8fnf29/summary-fail.json (live):/summary-fail.json (live): View Logs
[new_workspaces] debug.new_workspace timed 0 of 50 new workspace rows/
[new_workspaces] debug.new_workspace timed 0 of 50 new workspace rows
View Logs
[new_workspaces] the window draws no frames/[new_workspaces] the window draws no frames View Logs
[tabs] debug.tab_switch timed 0 of 40 switches/
[tabs] debug.tab_switch timed 0 of 40 switches
View Logs
[tabs] the window draws no frames/[tabs] the window draws no frames View Logs

Fix with [code]smith
Need help on this PR? Tag @codesmith-bot with what you need.

@cursor

cursor Bot commented Oct 27, 2026

Copy link
Copy Markdown

Bugbot needs on-demand usage enabled

Bugbot uses usage-based billing for this team and requires on-demand usage to be enabled.

A team admin can enable on-demand usage in the Cursor dashboard.

@teamleaderleo

Copy link
Copy Markdown
Collaborator Author

Review (codex gpt-6-astra xhigh, next-review): BLOCK at db82aef

  • ProviderDetector.swift:54 marks a provider unknown if any environment alias is malformed. Gemini’s resolver uses the first non-empty alias, so a valid GEMINI_API_KEY plus malformed GOOGLE_API_KEY is incorrectly shown as unknown and prompts for replacement. Validate only the effective first key.

@teamleaderleo

Copy link
Copy Markdown
Collaborator Author

Orphaned: no activity for 12 h, and no lane holds a lease on it. Adopted by the orphan sweep: merged feat-cmux-next in at ecace50. A later pass queues it for the merge hub if it is reviewed, small and red only on base reds.

@teamleaderleo

Copy link
Copy Markdown
Collaborator Author

Review (codex gpt-6-astra high, review-router): BLOCK at ecace50

VERDICT: BLOCK

  1. Packages/macOS/CmuxNext/Sources/CmuxNextCodeRouter/Detection/ProviderDetector.swift:54 — Any malformed Gemini alias forces .unknown, even when the higher-priority GEMINI_API_KEY is valid and the resolver would use it. Accounts incorrectly requests replacement credentials.

  2. Packages/macOS/CmuxNext/Sources/CmuxNextCodeRouter/Detection/ProviderDetector.swift:54 — Generic validation accepts a printable 16-character ANTHROPIC_API_KEY without the required sk-ant- prefix. Accounts reports .signedIn, then Connect immediately fails invalidFormat.

Agent session: agent session

teamleaderleo and others added 2 commits October 29, 2026 05:38
… rule

Detection now checks only the environment key Connect would read (the first
set in apiKeyEnvironmentKeys order), so a malformed GOOGLE_API_KEY no longer
marks Gemini unknown beside a valid GEMINI_API_KEY. Detection and the
resolver share one format rule, so an Anthropic key without the sk-ant-
prefix (or an OAuth token in ANTHROPIC_API_KEY) reads unknown instead of
signed in and then failing Connect with invalidFormat.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Agent-Session: https://cmux.com/deeplink/agent?id=aid-ab1f035a409b977caceb
@teamleaderleo

Copy link
Copy Markdown
Collaborator Author

Owned by an agent session · took over from an earlier session · session

Swift Testing decomposes tuple arguments only for pairs, so the four-field
tuple cases could not compile. Each case is now a KeyCase value.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Agent-Session: https://cmux.com/deeplink/agent?id=aid-ab1f035a409b977caceb
Detection trusts a key saved in cmux's Keychain by its presence (it never
reads the secret), so a malformed saved key read signed in and then failed
Connect with invalidFormat. Save now checks the key with Connect's own rule
(CredentialResolver.isWellFormedKey) and shows the invalid-format error.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Agent-Session: https://cmux.com/deeplink/agent?id=aid-ab1f035a409b977caceb
@teamleaderleo

Copy link
Copy Markdown
Collaborator Author

Review (codex gpt-6-astra high, review-router): SHIP at ba02d0a

No findings. Earlier blockers fixed: only the key Connect sends is judged (a malformed GOOGLE_API_KEY no longer hides a valid GEMINI_API_KEY); detection and Connect share one format rule (an Anthropic key without sk-ant- reads unknown); Save refuses a malformed key. ProviderDetectionSourcesTests and AccountsActionOutcomeTests pass on a fleet Mac at this head.

VERDICT: SHIP

Agent session: agent session

@teamleaderleo
teamleaderleo merged commit 79ff30e into feat-cmux-next Oct 29, 2026
200 of 205 checks passed
@teamleaderleo
teamleaderleo deleted the lane/ux-credentials-api branch October 29, 2026 18:42
@github-actions

github-actions Bot commented Oct 29, 2026 •

Copy link
Copy Markdown
Contributor

This branch was previously deployed

1 inactive deployment
ci-routing-agent — ba02d0a8 Deployed Oct 29, 2026 by teamleaderleo via namespace autofix #6244
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

risk:normal Risk tier (docs/ci/risk-tiers.md)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant