fix(api): validate create request bodies#101
Merged
Merged
Conversation
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.
Summary
POST /v1/endpointsrequest bodies with an API-local Zod schemaPOST /v1/tokensrequest bodies against the currentnamecontractinvalid_request/ HTTP 400 responses for non-object JSON and invalid field types{}behaviorWhy
The request readers previously cast any JSON object to the shared TypeScript request types. Invalid values such as
{ "name": 123 }were silently treated as an omitted name, while JSON primitives and arrays could continue into authentication or creation logic.The schemas remain in the API presentation layer because they currently have no runtime consumer outside the API. This avoids adding Zod as a shared-package runtime dependency.
TDD
Red:
namevalues and non-object JSON bodiesGreen/refactor:
{}after code reviewVerification
just ci-full: passedjust test-e2e: 1 file, 5 tests passedcode-reviewer: no remaining findings; initial Low test-gap finding addressedDocumentation
No documentation changes are required. This enforces the existing shared request contracts and does not implement the broader PAT scope, expiration, or idempotency requirements.
Closes #99