Skip to content

Generate key material when minting an API key for a user - #2903

Merged
lukemarsden merged 2 commits into
mainfrom
feature/002391-fix-critical-helixos
Jul 30, 2026
Merged

Generate key material when minting an API key for a user#2903
lukemarsden merged 2 commits into
mainfrom
feature/002391-fix-critical-helixos

Conversation

@binocarlos

Copy link
Copy Markdown
Collaborator

Follow-up to #2902 — that endpoint 500s on every call.

It went straight to Store.CreateAPIKey, which requires Key to be populated
already and rejects an empty one:

POST /api/v1/admin/users/{id}/api-keys?name=probe
500  failed to create API key: key not specified

Caught by probing the deployed endpoint on meta.helix.ml rather than by the unit
tests, which mocked the store and so happily accepted a key with no key in it.
That's the tell: the mock was asserting my assumption back at me.

Controller.CreateAPIKey is the correct path and what the self-serve create
handler already uses — it calls system.GenerateAPIKey() and stamps
Owner/OwnerType from the user passed in, so handing it targetUser keeps the
"owned by them, not by the admin who asked" property that #2902 was built around.

Testing

go test -run TestAdmin ./pkg/server/ passes. The mint test now builds a real
Controller around the mock store instead of calling the store directly, and
asserts the created key actually has key material — the thing whose absence the
previous version couldn't see.

Verified against the live endpoint that the route is deployed and reached my
handler; will re-probe once this ships to confirm a key actually comes back.

The mint endpoint called the store directly, which requires Key to be
set already and rejects an empty one with "key not specified" — so every
call 500'd. Caught probing the live endpoint. Use the controller, which
generates the key and stamps the owner from the user passed in, exactly
as the self-serve create path does.

Spec-Ref: helix-specs@6789a48:002391_fix-these-critical-bugs
DefaultWrapper flattens every error to 500, so the endpoint's 404 for
"this person has no Helix user" was indistinguishable from a genuine
failure. An orchestrator has to tell those apart: no account is the
expected case for someone who signed up there but never used Helix, and
it should fall back quietly, not log an outage.

Spec-Ref: helix-specs@6789a48:002391_fix-these-critical-bugs
@lukemarsden
lukemarsden merged commit eaef13d into main Jul 30, 2026
5 checks passed
@lukemarsden
lukemarsden deleted the feature/002391-fix-critical-helixos branch July 30, 2026 11:53
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