Skip to content

feat(apikeys): add rotate command#251

Open
LorrisSaintGenez wants to merge 3 commits into
feat/profile-deprfrom
feat/apikeys-rotate
Open

feat(apikeys): add rotate command#251
LorrisSaintGenez wants to merge 3 commits into
feat/profile-deprfrom
feat/apikeys-rotate

Conversation

@LorrisSaintGenez

@LorrisSaintGenez LorrisSaintGenez commented Jun 17, 2026

Copy link
Copy Markdown
Contributor

What

  • Add algolia apikeys rotate: rotates the CLI-managed API key for the current application via the Public API (POST .../api-keys/:uuid/rotate), looked up by the UUID stored in state.toml. The new key is persisted for the current application.
    • Legacy apps with no stored UUID get a clear error pointing to algolia application select.
  • Fix algolia application select and algolia auth login: a migrated app can have a usable key in the keychain but no api_key_uuid in state.toml (so rotate had nothing to target). Both now regenerate a fresh CLI-managed key whenever none is on record.

Test

# Rotate the current application's CLI-managed key
algolia apikeys rotate

# On a legacy/migrated app with no stored UUID → error pointing to 'application select'
algolia apikeys rotate

# 'application select' (or 'auth login') now stores a UUID; rotate then works
algolia application select
algolia apikeys rotate

GROUT-324

@codacy-production

codacy-production Bot commented Jun 17, 2026

Copy link
Copy Markdown

Up to standards ✅

🟢 Issues 0 issues

Results:
0 new issues

View in Codacy

🟢 Metrics 35 complexity · 16 duplication

Metric Results
Complexity 35
Duplication 16

View in Codacy

TIP This summary will be updated as you push new changes.

Add `algolia apikeys rotate` to rotate the CLI-managed API key for the
current application via the Public API (POST .../api-keys/:uuid/rotate),
looked up by the UUID stored in state.toml. The new key is persisted for
the current application.

- config: APIKeyUUID(appID) getter (legacy apps with no UUID return false)
- dashboard: RotateAPIKey client method
- rotate command: errors with a pointer to 'application select' when no
  CLI-managed key UUID is stored

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
A migrated application can have a usable key in the keychain but no
api_key_uuid in state.toml, so 'apikeys rotate' has nothing to target.
Both 'application select' and 'auth login' reused the existing key and
never generated a UUID. They now regenerate a fresh CLI-managed key
whenever none is on record.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@LorrisSaintGenez LorrisSaintGenez self-assigned this Jun 17, 2026
@LorrisSaintGenez LorrisSaintGenez marked this pull request as ready for review June 17, 2026 21:16
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