TRT-2771: Return HTTP 400 for invalid filter fields instead of 500 #3739
All Vouch review confidence checks passed
Residual risk 0.19 = Change Risk (0.43) × (1 − Review Confidence (0.57)).
Review depth and reviewer attention state are adequate.
Model 1 · Change Risk (XGBoost)
Score: 0.43 · 388 lines diff across 4 files
Model 2 · Review Depth (DistilBERT)
Depth Score: 0.17 · 1 substantive comment(s)
Model 3 · Review Timing & Attention
Session adequacy: 100% · Reviewer familiarity: 35%
Bedrock Claude 3 · Risk Narration
(disconnected)
Groq Risk Narration
AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
Model 1 · Change Risk Attribution
SHAP Weights
Diff Size
diff_size
0.357
Shallow Review Depth
shallow_review_depth
0.289
Real PR Conversation Timeline
1 comments
"Review active on #3739"
general
weight: 0.35
sosiouxme
Summary
FilterOptionsFromRequestandExtractFilterserror responses from 500 to 400 across all handlerserrors.Joinsopgconn.PgErroris detectable byerrors.Asat the boundaryContext
API clients sending filter parameters with unrecognized column names (e.g.,
columnField: "component"on/api/tests) caused database errors surfaced as HTTP 500 responses. The database already validates column names, so we catch those errors at the boundary layer rather than maintaining a parallel field list.Follow-up
Some
pkg/apifunctions (e.g.,PrintTestsJSONFromDB) write HTTP responses directly rather than returning errors to thesippyserverhandler layer. This creates two parallel error response paths (RespondWithErrorvsfailureResponseWithError). Unifying this by having allpkg/apifunctions return errors and lettingsippyserverhandle all HTTP responses is left for a follow-up refactor.Test plan
make lintpassesmake testpasses (14924 Go tests, 19 JS tests, 54 Python tests)Manual test evidence (against staging DB)
Invalid filter field (
component) on/api/testsreturns 400:Valid filter field (
name) on/api/testsreturns 200:Invalid filter field (
timestamp) on/api/jobsreturns 400:🤖 Generated with Claude Code
<!-- This is an auto-generated comment: release notes by coderabbit.ai -->
Summary by CodeRabbit
Bug Fixes
Improved API error handling so invalid request/filter parameters now return 400 Bad Request instead of server errors across multiple report and query endpoints.
Standardized JSON error responses and messages for job, test, release, and pull request reporting, including clearer “build report” failures.
Added consistent bad-request classification for PostgreSQL and BigQuery-style errors.
Tests
Added unit tests covering bad-request detection for PostgreSQL and Google API error variants.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->