Repository navigation
fix(api-keys): list, create and revoke agree with the route, and a real round trip pins it - #35
Merged
Merged
Conversation
…al round trip pins it
The api wraps every api-keys response in { data }. #744 and #30 unwrapped
update() and getUsage(); list(), create() and revoke() were left returning
the body verbatim, so list() handed callers an object typed as an array and
/office/api-keys crashed on `.map` for every office user (Scaffald/SaaS#1015).
- list(), create(), revoke() unwrap { data }.
- revoke() called POST /v1/api-keys/:id/revoke, a route that does not exist.
Revocation is DELETE /v1/api-keys/:id (a soft delete).
- The MSW mocks returned bare bodies and invented the /revoke route, so the
unit tests encoded the wrong contract and passed. They now return what the
route returns.
- The integration smoke accepted either shape; it is strict now. Its default
user has no organization, so it asserts the route's 403 for that case.
- api-keys.integration.test.ts: create -> list -> revoke -> list against the
real local api as a seeded team_admin. Red on the old resource (create()
returned the wrapper: `expected undefined to deeply equal Any<String>`),
green on this one.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
This was referenced Oct 6, 2026
thinkclay
added a commit
to Scaffald/SaaS
that referenced
this pull request
Oct 6, 2026
…with the route (#1050) Brings in Scaffald/sdk#35. The api wraps every api-keys response in { data }; list(), create() and revoke() returned the body verbatim (and revoke() called a route that does not exist), so /office/api-keys crashed into the error boundary on `x.map is not a function` for every office user (#1015). Co-authored-by: Claude Opus 5.5 <[email protected]>
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.
Fixes the SDK half of Scaffald/SaaS#1015:
/office/api-keyscrashes into the error boundary for every office user (TypeError: x.map is not a function at APIKeysList).Cause
The
apifunction wraps every api-keys response in{ data }. #744 and #30 unwrappedupdate()andgetUsage();list(),create()andrevoke()still returned the body verbatim. Solist()handed callers{data: [...]}typed asApiKey[].revoke()was also wrong in a second way: it POSTed to/v1/api-keys/:id/revoke, which does not exist. Revocation isDELETE /v1/api-keys/:id(a soft delete,is_active = false).Why the tests did not catch it
/revokeroute, so the unit tests encoded the wrong contract and passed.Array.isArray(result) ? result : result.data).Change
list(),create(),revoke()unwrap{ data };revoke()usesDELETE /:id.api-keys.integration.test.ts: create → list → revoke → list against the real localapias a seededteam_admin.Evidence
create()returned the wrapper:expected undefined to deeply equal Any<String>) and green on this one.SCAFFALD_INTEGRATION=1 pnpm test:integration(api-keys + endpoint smoke): 9/9.vitest run: 778/778.tsc --noEmitis clean andtsupbuilds.Found along the way (not fixed here)
The round trip defaults to
[email protected], not[email protected]. Every handler in the api route resolves the caller's org and role from one arbitrary team membership (.limit(1).single()). clay isteam_adminin four teams andmemberin three, so revoke refuses him. That will be filed on Scaffald/SaaS and fixed in the route.The SaaS side (pointer bump plus a capture of the screen working) follows once this merges.
🤖 Generated with Claude Code