Add centralized request-schema validation framework - #1030
Merged
Userunknown84 merged 1 commit intoJul 31, 2026
Conversation
|
@pavsoss is attempting to deploy a commit to the Aditya Sharma's projects Team on Vercel. A member of the Team first needs to authorize it. |
Userunknown84
approved these changes
Jul 31, 2026
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
Part 1 of 2 for #1024. Request validation was duplicated across handlers, each
re-checking body shape, field presence, types and allowed values inline and
returning its own error. This centralizes the contract: every endpoint declares
a schema once, and a single decorator enforces it before the handler runs.
Invalid requests now get a typed error that lists every offending field in
one response instead of stopping at the first problem. Per-field code and
message overrides mean migrated endpoints return exactly the errors they did
before, so existing clients see no change in accepted or rejected inputs.
jsonschemais not a project dependency and none is added; the validator is asmall in-house implementation covering presence, type, enum and length, plus
lenient query-parameter coercion that matches the previous behaviour. The
existing XSS/auth decorators are unchanged and still run.
Migrated:
/predict,/feedback,/feedback/stats,/importance,/spam-insights./analyze-email-headerregisters its contract for reuse butkeeps its file-vs-JSON presence check, which a flat body schema can't express.
Parts
Targets the default branch.
schemas, stacked on top of this.
Test plan
rejected with a typed envelope enumerating every bad field; presence, type,
enum, min/max length, non-object and malformed bodies, the aggregate
single-code case, and lenient query coercion.
codes, messages and status for each accepted and rejected input.
Refs #1024