fix: return HTTP 422 with field-level errors for JSON type mismatches#1090
Open
andyatmiami wants to merge 2 commits into
Open
fix: return HTTP 422 with field-level errors for JSON type mismatches#1090andyatmiami wants to merge 2 commits into
andyatmiami wants to merge 2 commits into
Conversation
Every handler that calls DecodeJSON previously returned a generic HTTP 400 for JSON type mismatches (e.g., sending "yes" for a bool field), leaking Go-internal error text. Now, json.UnmarshalTypeError is detected and converted to structured validation errors with the field path, expected type, and actual type — consistent with the existing failedValidationResponse infrastructure. Signed-off-by: Andy Stoneberg <astonebe@redhat.com> Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: The full list of commands accepted by this bot can be found here. DetailsNeeds approval from an approver in each of these files:Approvers can indicate their approval by writing |
Contributor
Author
|
/ok-to-test |
christian-heusel
suggested changes
May 11, 2026
Contributor
christian-heusel
left a comment
There was a problem hiding this comment.
Thanks for tackling this category of leftover todos 😄🚀
I have left a bit of review below 🤗
Signed-off-by: Andy Stoneberg <astonebe@redhat.com>
94d4798 to
10f00bd
Compare
christian-heusel
approved these changes
May 18, 2026
Contributor
christian-heusel
left a comment
There was a problem hiding this comment.
Nice work @andyatmiami and thanks for addressing all the feedback 🥳 💯
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.
ℹ️ NO GH ISSUE
Every handler that calls
DecodeJSONpreviously returned a generic HTTP400for JSON type mismatches (e.g., sending "yes" for a bool field), leaking Go-internal error text. Now,json.UnmarshalTypeErroris detected and converted to structured validation errors with the field path, expected type, and actual type — consistent with the existingfailedValidationResponseinfrastructure.