Skip to content

fix: return HTTP 422 with field-level errors for JSON type mismatches#1090

Open
andyatmiami wants to merge 2 commits into
kubeflow:notebooks-v2from
andyatmiami:chore/handle-unmarshal-type-error
Open

fix: return HTTP 422 with field-level errors for JSON type mismatches#1090
andyatmiami wants to merge 2 commits into
kubeflow:notebooks-v2from
andyatmiami:chore/handle-unmarshal-type-error

Conversation

@andyatmiami
Copy link
Copy Markdown
Contributor

ℹ️ NO GH ISSUE

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.

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>
@github-project-automation github-project-automation Bot moved this to Needs Triage in Kubeflow Notebooks May 10, 2026
@google-oss-prow google-oss-prow Bot added the area/backend area - related to backend components label May 10, 2026
@google-oss-prow google-oss-prow Bot added the area/v2 area - version - kubeflow notebooks v2 label May 10, 2026
@google-oss-prow
Copy link
Copy Markdown

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by:
Once this PR has been reviewed and has the lgtm label, please ask for approval from andyatmiami. For more information see the Kubernetes Code Review Process.

The full list of commands accepted by this bot can be found here.

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@andyatmiami
Copy link
Copy Markdown
Contributor Author

/ok-to-test

Copy link
Copy Markdown
Contributor

@christian-heusel christian-heusel left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for tackling this category of leftover todos 😄🚀

I have left a bit of review below 🤗

Comment thread workspaces/backend/api/helpers.go
Comment thread workspaces/backend/api/helpers.go
Comment thread workspaces/backend/api/helpers.go Outdated
Signed-off-by: Andy Stoneberg <astonebe@redhat.com>
@andyatmiami andyatmiami force-pushed the chore/handle-unmarshal-type-error branch from 94d4798 to 10f00bd Compare May 16, 2026 19:28
Copy link
Copy Markdown
Contributor

@christian-heusel christian-heusel left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice work @andyatmiami and thanks for addressing all the feedback 🥳 💯

@google-oss-prow google-oss-prow Bot added the lgtm label May 18, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/backend area - related to backend components area/v2 area - version - kubeflow notebooks v2 lgtm ok-to-test size/XL

Projects

Status: Needs Triage

Development

Successfully merging this pull request may close these issues.

2 participants