Skip to content

[WIP] TRT-2771: Return HTTP 400 for CR validation errors instead of 500#3777

Draft
mstaeble wants to merge 1 commit into
openshift:mainfrom
mstaeble:worktree-TRT-2771-cr-validation-errors
Draft

[WIP] TRT-2771: Return HTTP 400 for CR validation errors instead of 500#3777
mstaeble wants to merge 1 commit into
openshift:mainfrom
mstaeble:worktree-TRT-2771-cr-validation-errors

Conversation

@mstaeble

Copy link
Copy Markdown
Contributor

Summary

  • Introduces a ValidationError type in pkg/api recognized by IsBadRequestError, so component readiness handlers can rely on shared bad-request classification instead of hard-coding HTTP status codes
  • Wraps all parameter validation errors (missing releases, unknown view, bad dates, invalid int/bool params, missing test_id, missing dbGroupBy variants) with ValidationError
  • Fixes jsonComponentReportFromBigQuery which previously returned 400 for ALL errors including BQ server failures
  • Fixes jsonComponentReportTestDetailsFromBigQuery which previously returned 500 for validation errors like missing test_id
  • Preserves multi-error logging when GetTestDetails returns more than one error

Context

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 lint passes (0 issues)
  • make test passes (13775 Go tests, 19 JS tests, 53 Python tests)
  • IsBadRequestError unit tests cover ValidationError (direct and wrapped)
  • Manual: curl /api/component_readiness?view=bogus returns 400
  • Manual: curl /api/component_readiness/test_details?view=... without testId returns 400
  • Manual: valid component readiness request returns 200

@coderabbitai ignore

🤖 Generated with Claude Code

@openshift-merge-bot

Copy link
Copy Markdown
Contributor

Pipeline controller notification
This repo is configured to use the pipeline controller. Second-stage tests will be triggered either automatically or after lgtm label is added, depending on the repository configuration. The pipeline controller will automatically detect which contexts are required and will utilize /test Prow commands to trigger the second stage.

For optional jobs, comment /test ? to see a list of all defined jobs. To trigger manually all jobs from second stage use /pipeline required command.

This repository is configured in: automatic mode

@openshift-ci openshift-ci Bot added the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Jul 15, 2026
@openshift-ci-robot openshift-ci-robot added the jira/valid-reference Indicates that this PR references a valid Jira ticket of any type. label Jul 15, 2026
@openshift-ci

openshift-ci Bot commented Jul 15, 2026

Copy link
Copy Markdown
Contributor

Skipping CI for Draft Pull Request.
If you want CI signal for your change, please convert it to an actual PR.
You can still manually trigger a test run with /test all

@openshift-ci-robot

openshift-ci-robot commented Jul 15, 2026

Copy link
Copy Markdown

@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.

Details

In response to this:

Summary

  • Introduces a ValidationError type in pkg/api recognized by IsBadRequestError, so component readiness handlers can rely on shared bad-request classification instead of hard-coding HTTP status codes
  • Wraps all parameter validation errors (missing releases, unknown view, bad dates, invalid int/bool params, missing test_id, missing dbGroupBy variants) with ValidationError
  • Fixes jsonComponentReportFromBigQuery which previously returned 400 for ALL errors including BQ server failures
  • Fixes jsonComponentReportTestDetailsFromBigQuery which previously returned 500 for validation errors like missing test_id
  • Preserves multi-error logging when GetTestDetails returns more than one error

Context

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 lint passes (0 issues)
  • make test passes (13775 Go tests, 19 JS tests, 53 Python tests)
  • IsBadRequestError unit tests cover ValidationError (direct and wrapped)
  • Manual: curl /api/component_readiness?view=bogus returns 400
  • Manual: curl /api/component_readiness/test_details?view=... without testId returns 400
  • Manual: valid component readiness request returns 200

@coderabbitai ignore

🤖 Generated with Claude Code

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.

@openshift-ci openshift-ci Bot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Jul 15, 2026
@openshift-ci

openshift-ci Bot commented Jul 15, 2026

Copy link
Copy Markdown
Contributor

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: mstaeble
Once this PR has been reviewed and has the lgtm label, please assign sosiouxme for approval. For more information see the 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

@coderabbitai

coderabbitai Bot commented Jul 15, 2026

Copy link
Copy Markdown
Contributor

Tip

For best results, initiate chat on the files or code changes.

@openshift-ci-robot This is an automated Jira validation notice, not a request for CodeRabbit review. Additionally, this PR's description includes @coderabbitai ignore, so I won't be taking any review action here. The Jira target version warning should be addressed by the PR author (@mstaeble) directly in Jira.

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>
@mstaeble mstaeble force-pushed the worktree-TRT-2771-cr-validation-errors branch from 86a2103 to d66afed Compare July 15, 2026 12:59
@openshift-ci openshift-ci Bot removed the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Jul 15, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. jira/valid-reference Indicates that this PR references a valid Jira ticket of any type.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants