Skip to content

fix: read legacy ~/.upstash.json so 0.x users stay logged in - #14

Merged
ytkimirti merged 1 commit into
mainfrom
fix/legacy-config-fallback
Jun 25, 2026
Merged

fix: read legacy ~/.upstash.json so 0.x users stay logged in#14
ytkimirti merged 1 commit into
mainfrom
fix/legacy-config-fallback

Conversation

@ytkimirti

Copy link
Copy Markdown
Contributor

The 1.0 rewrite moved saved credentials from ~/.upstash.json to ~/.config/upstash/config.json and renamed the JSON key apiKey to api_key. As a result, anyone upgrading from the 0.x CLI silently appears logged out (and any script passing the old -c/--config flag already errors).

This adds a read-only fallback so existing users keep working:

  • readConfig() now reads the new config first, then falls back to the legacy ~/.upstash.json, accepting either the new api_key or the legacy apiKey.
  • The new config always wins, so the first upstash login transparently migrates a user onto the new path.
  • The legacy path is overridable via UPSTASH_LEGACY_CONFIG_HOME (mirrors UPSTASH_CONFIG_HOME) purely so tests stay isolated.

Scope is intentionally small: this is read-only. We never write or delete ~/.upstash.json (upstash logout still only manages the new file).

Tests: 3 new unit tests cover the legacy read, new-over-legacy precedence, and a malformed legacy file. Typecheck + build + unit suite green.

The 1.0 rewrite moved credentials to ~/.config/upstash/config.json and
renamed the JSON key apiKey -> api_key, so users upgrading from the 0.x
CLI silently appeared logged out. readConfig() now falls back to the
legacy ~/.upstash.json (accepting the old camelCase apiKey) when no new
config is present. The new config still takes precedence, so re-running
`upstash login` transparently migrates them.
@ytkimirti
ytkimirti merged commit 890bb50 into main Jun 25, 2026
2 checks passed
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