Repository navigation
[3.0] workloads: validate sortBy on priorities endpoints - #1406
Conversation
Map the sortBy query parameter through the priorities field mapping before it reaches the DAO, matching the workloads, pods, applications and templates endpoints. Unknown values now return 400 instead of being passed to ORDER BY. Covers GetWorkloadPriorities, GetWorkloadClusterPriorities and GetAvailablePrioritiesAndCategories (which delegates to the cluster variant). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Signed-off-by: Natasha Romm <nromm@nvidia.com>
|
Important Review skippedAuto reviews are disabled on base/target branches other than the default branch. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Repository: dsx-ai-factory/run-ai/.coderabbit.yaml Review profile: CHILL Plan: Enterprise Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
Comment |
GetAvailablePrioritiesAndCategories turned every non-200 response from GetWorkloadClusterPriorities into 503, so an invalid sortBy or filterBy (400) or a scope denial (403) looked like a service outage. Pass those responses through and keep 503 for actual errors. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Signed-off-by: Natasha Romm <nromm@nvidia.com>
🔎 env-in-a-click failure — automated root-causeEnvironment: Symptom — The Root cause — The Log excerpt (only this one log line was captured for Generated from the env-in-a-click MCP debug tools · failing run |
Summary
The workload priorities endpoints validated
filterBybut passedsortBystraight to the DAO, where it was formatted into theORDER BYclause. This mapssortBythrough the priorities field mapping (queryapi.Parser.GetMapping) first, the same pattern already used by the workloads, pods, applications and templates list endpoints. Unknown values now return 400.Endpoints covered:
GetWorkloadPrioritiesGetWorkloadClusterPrioritiesGetAvailablePrioritiesAndCategories(delegates to the cluster variant)The allowed fields are the existing
FilterFieldsToColumn()maps, which match the swaggersortByenums (name, source, value, plusphasefor the cluster view). An emptysortBybehaves as before.Out of scope
dbenrich.FormatSortClauseitself still concatenates its input; all other callers validate upstream. Hardening the shared helper can be a separate follow-up.Testing
DescribeTableinworkload_properties_api_test.go: unknown field, raw column name and SQL payloads are rejected with 400 on both endpoints.go test ./...incontrol-plane/workloadspasses.Summary by CodeRabbit
Cherry-picked from #1404
🤖 Generated with Claude Code