Skip to content

fix(auth): keep auth.json entries with non-string metadata and never drop them on write - #2830

Merged
yanyihan-xiaomi merged 3 commits into
mainfrom
fix/auth-metadata-tolerant
Nov 18, 2026
Merged

yanyihan-xiaomi merged 3 commits into
mainfrom
fix/auth-metadata-tolerant

Conversation

@yanyihan-xiaomi

Copy link
Copy Markdown
Collaborator

MiMo Desktop's one-click platform link writes metadata.platform_linked: true (a boolean). The CLI's Auth.Api schema declares metadata as Record<string, string>, so:

  • Auth.all() silently dropped those xiaomi / xiaomi-token-plan-* credentials, and requests went out with no valid key (401 Invalid API Key).
  • Auth.set / Auth.remove rewrote the file from the decoded view. Re-linking one provider in the CLI therefore erased the other Desktop-linked entry, leaving only xiaomi-token-plan-cn.

Fix:

  • On read from disk, keep only the string fields of an api entry's metadata before decoding. The public Auth.Info type is unchanged.
  • set / remove now change the raw JSON, so entries and fields the CLI does not understand are kept.

Spec: docs/compose/spec/auth-metadata-tolerant.md

Verification: 2 regression tests in test/auth (both failed on base); test/provider + test/cli 1048 pass; typecheck pass. Manual check with a Desktop-shaped auth.json and providers list: base shows 0 credentials, this branch shows 2.

@yanyihan-xiaomi
yanyihan-xiaomi merged commit 75e1ed0 into main Nov 18, 2026
6 checks passed
@yanyihan-xiaomi
yanyihan-xiaomi deleted the fix/auth-metadata-tolerant branch November 18, 2026 08:40
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.

1 participant