fix: migrate management keys to private REST API - #7
Merged
Conversation
Registration was still failing with `management_key_create_failed` /
`could not get create action hash, available: map[]`. The previous commit
migrated account state; the provisioning-key lifecycle was still on the
server actions OpenRouter removed.
Endpoints derived from the authenticated bundle (module 677420, hooks
useCreateManagementApiKey / useDeleteWorkspaceApiKey):
list GET /api/frontend/v1/private/management-keys?page=N
create POST /api/frontend/v1/private/workspace-api-keys/management
delete PATCH /api/frontend/v1/private/workspace-api-keys/{hash}
{"payload":{"deleted":true},"opts":{"is_provisioning_key":true}}
The delete opts flag is required and must be snake_case: the endpoint answers
403 for opts:{} and for opts:{"isProvisioningKey":true}, matching the third
argument the old server action passed.
Listing now paginates. This is a correctness fix beyond the migration: the
legacy path scraped the settings page and only ever saw the first 20 keys, so
CleanupProvisioningKeys silently under-reported on busy accounts. The test
account holds 164 management keys, of which the old path could see ~20.
All three exported functions try REST first and keep the legacy server-action
path as a fallback, consistent with FetchActivityData.
Verified end-to-end against a live account through the exported Go API, with
`action hashes: map[]` throughout: listed 164 keys (proving pagination),
created a key, found it by label, deleted it via CleanupProvisioningKeys, and
confirmed the count returned to 164 -- the probe left no residue.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Symptom
Registration still failing after #6:
{"reason":"management_key_create_failed", "error_detail":"could not get create action hash, available: map[]"}#6 migrated account state; the provisioning-key lifecycle was still on the server actions OpenRouter removed. This is the remaining half.
Endpoints
Derived from the authenticated bundle — module
677420, hooksuseCreateManagementApiKey/useDeleteWorkspaceApiKey:GET /api/frontend/v1/private/management-keys?page=NPOST /api/frontend/v1/private/workspace-api-keys/managementPATCH /api/frontend/v1/private/workspace-api-keys/{hash}Delete body:
{"payload":{"deleted":true},"opts":{"is_provisioning_key":true}}That
optsflag is required and must be snake_case — the endpoint answers403foropts:{}and foropts:{"isProvisioningKey":true}. It corresponds to the third argument the old server action passed ({"isProvisioningKey":true}), which is how it was found.Listing now paginates — a correctness fix beyond the migration
The legacy path scraped the settings page and only ever saw the first 20 keys.
CleanupProvisioningKeysdeletes keys whose name matches a station label, so on a busy account it was silently leaving keys alive and under-reporting the count. The test account holds 164 management keys; the old path could see roughly 20 of them.Verification
End-to-end against a live account through the exported Go API (not curl), with
action hashes: map[]throughout — proving none of it touches the removed actions:The probe key is created under a dedicated label and removed via
CleanupProvisioningKeys, so the live test leaves the account exactly as it found it — and it exercises the label-matching cleanup path rather than just the raw delete.Unit tests cover the list envelope,
total_count, hashless entries (which would give cleanup an undeletable target), error/HTML bodies, and the empty page that terminates pagination.All three exported functions try REST first and keep the legacy server-action path as a fallback, consistent with
FetchActivityDatain #6.🤖 Generated with Claude Code