Skip to content

fix(cli): preserve selected auth type on startup auth failure#2080

Open
zy6p wants to merge 1 commit intoQwenLM:mainfrom
zy6p:fix/2049-preserve-selected-auth-type-on-auth-failure
Open

fix(cli): preserve selected auth type on startup auth failure#2080
zy6p wants to merge 1 commit intoQwenLM:mainfrom
zy6p:fix/2049-preserve-selected-auth-type-on-auth-failure

Conversation

@zy6p
Copy link
Contributor

@zy6p zy6p commented Mar 4, 2026

TLDR

Stop clearing security.auth.selectedType when startup auto-auth fails.

This preserves user auth configuration (for example OpenAI-compatible + custom envKey) and avoids rewriting settings.json into a confusing state when an env var is temporarily missing.

Dive Deeper

Root cause:

  • initializeApp() called settings.setValue(..., 'security.auth.selectedType', undefined) whenever performInitialAuth() returned an error.
  • For setups like envKey: OLLAMA_API_KEY, forgetting to export the env var made startup auth fail and wiped selectedType from user settings.

What changed:

  • Removed the destructive fallback write in packages/cli/src/core/initializer.ts.
  • Kept the existing UX behavior: auth error still opens auth dialog (shouldOpenAuthDialog remains true).
  • Added regression tests in packages/cli/src/core/initializer.test.ts.

Reviewer Test Plan

  1. Configure settings.json with:
    • security.auth.selectedType = "openai"
    • an OpenAI-compatible model that uses a custom envKey (e.g. OLLAMA_API_KEY)
  2. Ensure that env key is missing in shell (unset OLLAMA_API_KEY).
  3. Start qwen.
  4. Verify:
    • auth error is shown and auth dialog opens
    • settings.json still keeps security.auth.selectedType unchanged

Testing Matrix

🍏 🪟 🐧
npm run
npx
Docker
Podman - -
Seatbelt - -

Linked issues / bugs

Fixes #2049

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.

security.auth.selectedType overrided when OLLAMA_API_KEY is not exported

2 participants