fix(server): return 204 from registerUser when no auth is issued - #7042
Merged
Conversation
The handler returned 200 with an empty body for open registrations (no invitation `sig`). The OpenAPI spec declared no response schema, so codegen tools typed the return as `void`. The invited-user path that does return `UserAuthResponse` was undocumented. Split into 200 (with `userAuth` schema, invitation flow) and 204 (no body, open registration) so the generated client carries the correct return type and `customInstance` handles the empty response through its existing 204 path.
Member
|
/review |
|
Claude finished @otavio's task in 1m 15s —— View job Code Review CompleteReviewed 2 files across code quality, security, testing, language patterns, and architecture — no new issues found. The code looks good as-is. A few notes confirming the change is sound:
If you push additional changes and want a new review, tag |
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.
What
POST /api/registernow returns 204 (no body) for open registrations and 200 withuserAuthcredentials for invitation-based registrations. The OpenAPI spec documents both paths.Why
The handler returned 200 for both cases — with a
UserAuthResponsebody on the invitation path and an empty body on the open-registration path. The spec declared no response schema at all, so codegen tools (hey-api, Orval) typed the return asvoid. The invited-user flow that auto-logs in after signup relied on readingtokenandtenantfrom the response, which the generated type said didn't exist.This surfaced during the Orval migration (#7023):
customInstancecallsresponse.json()on every non-204 response, so an empty 200 body throws aSyntaxErrorinstead of succeeding silently like hey-api did.Changes
server/api/routes/invitation.go:RegisterUserreturnshttp.StatusNoContentinstead ofhttp.StatusOKwhenauthInfois nil (open registration, no credentials to return)openapi/spec/paths/api@register.yaml: split the 200 response into 200 (withuserAuthschema) and 204 (no body), so codegen produces the correct return typeTesting
Register via both paths and verify the status codes:
sig): should return 204sigwhere the user is auto-confirmed: should return 200 withtokenandtenantin the JSON body