Skip to content

feat(auth): add read-only auth status command#263

Open
LorrisSaintGenez wants to merge 5 commits into
mainfrom
feat/auth-status
Open

feat(auth): add read-only auth status command#263
LorrisSaintGenez wants to merge 5 commits into
mainfrom
feat/auth-status

Conversation

@LorrisSaintGenez

@LorrisSaintGenez LorrisSaintGenez commented Jul 9, 2026

Copy link
Copy Markdown
Contributor

What

  • New algolia auth status: reports whether you're signed in (and as whom), which application is current, and whether an API key is available — with a non-zero exit code when neither a session nor API credentials are found. Strictly read-only: never prompts, opens a browser, or mutates stored credentials (unlike auth get, which triggers the OAuth flow when logged out). Flags active environment overrides (ALGOLIA_APPLICATION_ID, ALGOLIA_API_KEY, ALGOLIA_ADMIN_API_KEY deprecated, ALGOLIA_SEARCH_HOSTS with its value) so misdirected requests are diagnosable at a glance.
  • The auth group description now mentions sign-up and status.
  • Actionable auth error hints: when you're signed in but no application is selected, the failure now says Run algolia application select, or pass --application-id instead of the misleading Please run algolia auth login; the keychain-missing error keeps its own remediation without a contradictory extra line.
  • auth get no longer panics (nil dereference) when authentication succeeds but the token cannot be persisted to the OS keychain — it returns a clear error instead.

Why the pkg/config changes are in this PR

  • validators.go + profile.go: the hint logic in root.go needs to distinguish "key missing from keychain" from the generic auth errors via errors.Is, so the existing inline error string becomes the ErrAPIKeyMissingFromKeychain sentinel, wrapped with %w where it was produced. The user-facing message is byte-for-byte identical.
  • resolution_test.go: pre-existing flake surfaced while running the suite for this PR — the GetSearchHosts tests read the ambient environment, so they fail on any machine where the repo's .env (direnv) is loaded. Two t.Setenv lines neutralize it. Happy to split it out if preferred.

Test

algolia auth status                                        # signed in: ✓ session, ✓ current app, ✓ API key
ALGOLIA_SEARCH_HOSTS=c1-test-1.algolianet.com algolia auth status   # warns that API requests go to that host
XDG_CONFIG_HOME=$(mktemp -d) ALGOLIA_APPLICATION_ID= ALGOLIA_API_KEY= algolia auth status; echo $?   # exit 1 when nothing usable

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@codacy-production

codacy-production Bot commented Jul 9, 2026

Copy link
Copy Markdown

Up to standards ✅

🟢 Issues 0 issues

Results:
0 new issues

View in Codacy

🟢 Metrics 27 complexity · 6 duplication

Metric Results
Complexity 27
Duplication 6

View in Codacy

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

LorrisSaintGenez and others added 3 commits July 9, 2026 12:06
…cation

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@LorrisSaintGenez LorrisSaintGenez self-assigned this Jul 9, 2026
@LorrisSaintGenez LorrisSaintGenez marked this pull request as ready for review July 9, 2026 20:54
Co-Authored-By: Claude Fable 5 <noreply@anthropic.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.

1 participant