Skip to content

Conversation

@dylantientcheu
Copy link
Collaborator

Problem

The algolia profile add command was failing with invalid application credentials when users tried to add a profile using an Admin API Key. This is problematic because not all users have access to Write API Keys, and Admin API Keys should be supported.

Root Cause

The command was detecting Admin API Keys correctly via ListApiKeys(), but then still attempting to fetch ACLs using GetApiKey(<admin key>). Admin API Keys cannot be retrieved as API key objects via the /1/keys/{key} endpoint, causing the validation to fail.

Solution

  • Refactored API key inspection into a separate inspectAPIKey function that properly handles Admin API Keys
  • When an Admin API Key is detected (via successful ListApiKeys() call), we skip the GetApiKey() call entirely
  • Updated the interactive prompt from "(Write) API Key" to "API Key" to reflect that both Admin and Write keys are supported
  • Added comprehensive unit tests for the new inspectAPIKey function

Additional Changes

  • Fixed flaky test in apikeys list command by making time-based output deterministic

Testing

  • All existing tests pass
  • Added new test cases for Admin API Key handling
  • Verified the fix works with both Admin and Write API Keys

@dylantientcheu dylantientcheu merged commit 9f78630 into main Dec 16, 2025
3 checks passed
@dylantientcheu dylantientcheu changed the title Fix: Enable Admin API Key support in profile add command Fix: Enable Admin API Key support in profile add command [CR-10035] Dec 16, 2025
@dylantientcheu dylantientcheu deleted the fix/profile-add-key-issues branch December 16, 2025 13:17
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.

2 participants