[WIP] TRT-2771: Return HTTP 400 for CR validation errors instead of 500#3777
[WIP] TRT-2771: Return HTTP 400 for CR validation errors instead of 500#3777mstaeble wants to merge 1 commit into
Conversation
|
Pipeline controller notification For optional jobs, comment This repository is configured in: automatic mode |
|
Skipping CI for Draft Pull Request. |
|
@mstaeble: This pull request references TRT-2771 which is a valid jira issue. Warning: The referenced jira issue has an invalid target version for the target branch this PR targets: expected the story to target the "5.0.0" version, but no target version was set. DetailsIn response to this:
Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the openshift-eng/jira-lifecycle-plugin repository. |
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: mstaeble 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 |
|
Tip For best results, initiate chat on the files or code changes.
|
Introduce a ValidationError type recognized by IsBadRequestError so that component readiness handlers can rely on shared bad-request classification instead of hard-coding HTTP status codes. - Add ValidationError to pkg/api and extend IsBadRequestError to detect it - Wrap validation errors in test_details.go (missing test_id, missing dbGroupBy variants) and queryparamparser.go (missing releases, unknown view, bad dates, invalid int/bool params) - Switch jsonComponentReportFromBigQuery to failureResponseWithError for auto-classification (fixes false 400 on BQ server errors) - Switch jsonComponentReportTestDetailsFromBigQuery to failureResponseWithError (fixes false 500 on validation errors) - Log all errors from GetTestDetails before classifying the first Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
86a2103 to
d66afed
Compare
Summary
ValidationErrortype inpkg/apirecognized byIsBadRequestError, so component readiness handlers can rely on shared bad-request classification instead of hard-coding HTTP status codesValidationErrorjsonComponentReportFromBigQuerywhich previously returned 400 for ALL errors including BQ server failuresjsonComponentReportTestDetailsFromBigQuerywhich previously returned 500 for validation errors like missing test_idGetTestDetailsreturns more than one errorContext
Follow-up to #3739 which fixed 400/500 classification for filter/sort field errors across most endpoints. The component readiness handlers were not covered by that PR and had two problems: the component report handler hard-coded 400 for all errors (including server failures), and the test details handler hard-coded 500 for all errors (including validation failures).
Test plan
make lintpasses (0 issues)make testpasses (13775 Go tests, 19 JS tests, 53 Python tests)IsBadRequestErrorunit tests coverValidationError(direct and wrapped)curl /api/component_readiness?view=bogusreturns 400curl /api/component_readiness/test_details?view=...without testId returns 400@coderabbitai ignore
🤖 Generated with Claude Code