Skip to content

fix: reject empty Kubernetes resource names in tRPC input schemas - #400

Open
AnKiT-GaRG2 wants to merge 1 commit into
volcano-sh:mainfrom
AnKiT-GaRG2:fix/287-reject-empty-k8s-identifiers
Open

AnKiT-GaRG2 wants to merge 1 commit into
volcano-sh:mainfrom
AnKiT-GaRG2:fix/287-reject-empty-k8s-identifiers

Conversation

@AnKiT-GaRG2

Copy link
Copy Markdown

Fixes #287

  • Adds a shared k8sIdentifierSchema (z.string().trim().min(1)) and uses it for name and namespace on the get/update/delete inputs for jobs, pods, queues and podgroups (queues only name). List, pagination and filter schemas are unchanged.
  • As noted on the issue, stricter schemas would break the YAML detail modals, because they used disabled queries built from the previous selection and sent empty values on the first click. The handlers now fetch the YAML with the clicked row's identifiers via utils.<router>.<proc>.fetch(...), as the edit handlers already do, and the unused queries are removed.

turbo run check-types lint passes (only the existing useCallback dependency warnings). A quick script confirmed empty and whitespace-only names are rejected and valid ones accepted. I did not test the modals in a browser, and there is no test setup in the repo.

AI disclosure: an AI coding assistant helped prepare this change. The checks above were run locally.

@volcano-sh-bot

Copy link
Copy Markdown
Contributor

[APPROVALNOTIFIER] This PR is NOT APPROVED

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

@volcano-sh-bot

Copy link
Copy Markdown
Contributor

Welcome @AnKiT-GaRG2! It looks like this is your first PR to volcano-sh/dashboard 🎉

Add a shared k8sIdentifierSchema (trimmed, min length 1) for the name and namespace of get/update/delete inputs for jobs, pods, queues and podgroups. List, pagination and filter schemas are unchanged.

The YAML detail views used disabled queries initialised from the previous selection, so the first click sent empty identifiers. Fetch the YAML with the clicked row's identifiers instead so the modals keep working with the stricter schemas.

Signed-off-by: Ankit Garg <146389256+AnKiT-GaRG2@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

fix: Zod Validation Allows Empty Kubernetes Resource Names

2 participants