Skip to content

[3.0] workloads: validate sortBy on priorities endpoints - #1406

Merged
natasharomm merged 3 commits into
release-3.0from
natasha/3-0-fix-priorities-sortby-validation
Oct 1, 2026
Merged

natasharomm merged 3 commits into
release-3.0from
natasha/3-0-fix-priorities-sortby-validation

Conversation

@natasharomm

Copy link
Copy Markdown
Contributor

Summary

The workload priorities endpoints validated filterBy but passed sortBy straight to the DAO, where it was formatted into the ORDER BY clause. This maps sortBy through 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:

  • GetWorkloadPriorities
  • GetWorkloadClusterPriorities
  • GetAvailablePrioritiesAndCategories (delegates to the cluster variant)

The allowed fields are the existing FilterFieldsToColumn() maps, which match the swagger sortBy enums (name, source, value, plus phase for the cluster view). An empty sortBy behaves as before.

Out of scope

dbenrich.FormatSortClause itself still concatenates its input; all other callers validate upstream. Hardening the shared helper can be a separate follow-up.

Testing

  • New DescribeTable in workload_properties_api_test.go: unknown field, raw column name and SQL payloads are rejected with 400 on both endpoints.
  • go test ./... in control-plane/workloads passes.

Summary by CodeRabbit

  • Bug Fixes
    • Priority endpoints now return a bad-request response for unsupported sort fields, including raw database columns and SQL-like sort expressions.

Cherry-picked from #1404

🤖 Generated with Claude Code

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>
@natasharomm
natasharomm requested a review from a team as a code owner October 1, 2026 08:16
@coderabbitai

coderabbitai Bot commented Oct 1, 2026 •

Copy link
Copy Markdown
Contributor

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Repository: dsx-ai-factory/run-ai/.coderabbit.yaml

Review profile: CHILL

Plan: Enterprise

Run ID: 6b8c4df5-061c-40fa-a0b7-9f4a64d10a42

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
  • Autopilot · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Autopilot is currently an internal CodeRabbit preview.


Comment @coderabbitai help to get the list of available commands.

@github-actions

github-actions Bot commented Oct 1, 2026

Copy link
Copy Markdown
Contributor

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>
@github-actions

github-actions Bot commented Oct 1, 2026

Copy link
Copy Markdown
Contributor

@natasharomm
natasharomm enabled auto-merge (squash) October 1, 2026 08:42
@circleci-runai

Copy link
Copy Markdown
Contributor

🔎 env-in-a-click failure — automated root-cause

Environment: ci-32ff-natasha3-0-fix-priori

Symptom — The create-runai wave job failed during the terraform apply / Helm upgrade phase (3 attempts, BackoffLimitExceeded), leaving the environment Degraded for 29m.

Root cause — The runai-cluster Helm release upgrade aborted because its pre-upgrade hook for the gpu-fractioning CRD failed, in the last wave-job pod create-runai-6bclc (same failure in prior attempts create-runai-krpz5 and create-runai-k2tn5): Error: pre-upgrade hooks failed: warning: Hook pre-upgrade runai-cluster/charts/kai-resource-management/charts/kai-scheduler/charts/gpu-fractioning/templates/crd.yaml failed: 1 error occurred:. The inner cluster is reachable and its control-plane/runai pods are Running, so the failure is confined to the Helm hook; the nested detail after 1 error occurred: is truncated in the captured diagnostics.

Log excerpt

2026-10-01T09:08:56.155822801Z ESC[31m│ESC[0m ESC[0mESC[1mESC[31mError: ESC[0mESC[0mESC[1mpre-upgrade hooks failed: warning: Hook pre-upgrade runai-cluster/charts/kai-resource-management/charts/kai-scheduler/charts/gpu-fractioning/templates/crd.yaml failed: 1 error occurred:

(only this one log line was captured for create-runai-6bclc/terraform; the identical error line appears for create-runai-krpz5 at 09:03:58 and create-runai-k2tn5 at 09:06:23 — full hook output is not in these diagnostics, see the run logs for the untruncated terraform output.)

Generated from the env-in-a-click MCP debug tools · failing run

@github-actions

github-actions Bot commented Oct 1, 2026

Copy link
Copy Markdown
Contributor

@natasharomm
natasharomm merged commit de060f5 into release-3.0 Oct 1, 2026
18 checks passed
@natasharomm
natasharomm deleted the natasha/3-0-fix-priorities-sortby-validation branch October 1, 2026 11:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants