Skip to content

Fix auth switch writing bogus default entry into auth-contexts#1874

Open
cipheraxat wants to merge 1 commit into
digitalocean:mainfrom
cipheraxat:fix/auth-switch-default-context-pollution
Open

Fix auth switch writing bogus default entry into auth-contexts#1874
cipheraxat wants to merge 1 commit into
digitalocean:mainfrom
cipheraxat:fix/auth-switch-default-context-pollution

Conversation

@cipheraxat

@cipheraxat cipheraxat commented Jul 10, 2026

Copy link
Copy Markdown

Summary

  • Stop injecting a synthetic default key into auth-contexts when running doctl auth switch --context default, which previously caused writeConfig() to persist default: "true".
  • Avoid mutating the caller's map in ensureDefaultContextAndKeysOrder so auth list cannot dirty Viper state before a later config write.
  • Add unit and integration coverage that switching back to default leaves named contexts intact without a bogus default entry.

Fixes #1816

Test plan

  • Reproduced the bug on an unfixed build: auth switch --context default wrote default: "true" under auth-contexts
  • Confirmed fixed build no longer writes that entry; context: default is set and named contexts remain
  • Confirmed auth list still shows default (current) and a switch roundtrip stays clean
  • go test ./commands/ -run 'Auth|displayAuth|EnsureDefault'
  • go test -mod=vendor ./integration -run 'TestRun/doctl/auth' (12 passed)

Stop injecting a synthetic default key into auth-contexts during
validation so writeConfig no longer persists default: "true".

Fixes digitalocean#1816

Co-authored-by: Cursor <cursoragent@cursor.com>
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.

auth switch --context default writes bogus "default: true" into auth-contexts

1 participant