Skip to content

Fix runAsUser and fsGroup validation error when clearing fields#17450

Merged
codyrancher merged 2 commits into
rancher:masterfrom
codyrancher:issue-9601
May 27, 2026
Merged

Fix runAsUser and fsGroup validation error when clearing fields#17450
codyrancher merged 2 commits into
rancher:masterfrom
codyrancher:issue-9601

Conversation

@codyrancher
Copy link
Copy Markdown
Member

@codyrancher codyrancher commented May 1, 2026

Summary

Fixes #9601

Occurred changes and/or fixed issues

Clearing runAsUser or fsGroup inputs sent "" or null instead of omitting the key.

Technical notes summary

  • Strip null, "" and undefined values for fsGroup/runAsUser in Security.vue's update() before emit
  • Add type="number" min="0" to runAsUser input (was missing); add min="0" to fsGroup input

Areas or cases that should be tested

  • Edit a Deployment with runAsUser set, clear the field, save - should succeed
  • Same for fsGroup on the pod security context tab

Areas which could experience regressions

  • Workload forms using the Security component

Screenshot/Video

Before fix - clearing Run as User ID and saving produces cannot unmarshal string into Go struct field of type int64:

repro-issue-9601.webm

After fix - clearing Run as User ID and saving succeeds, redirects to deployment list:

demo-fix.webm

Checklist

  • The PR is linked to an issue and the linked issue has a Milestone, or no issue is needed
  • The PR has a Milestone
  • The PR template has been filled out
  • The PR has been self reviewed
  • The PR has a reviewer assigned
  • The PR has automated tests or clear instructions for manual tests and the linked issue has appropriate QA labels, or tests are not needed
  • The PR has reviewed with UX and tested in light and dark mode, or there are no UX changes
  • The PR has been reviewed in terms of Accessibility
  • The PR has considered, and if applicable tested with, the three Global Roles Admin, Standard User and User Base

Clearing the field left an empty string in the spec; Kubernetes then rejected
the save with "cannot unmarshal string ... of type int64". Also use a numeric
input with min=0 for both fields so the empty-string path is harder to hit and
non-numeric input is blocked at the UI.

Fixes rancher#9601
@rancher-ui-project-bot rancher-ui-project-bot Bot added this to the v2.15.0 milestone May 1, 2026
@codyrancher codyrancher requested a review from torchiaf May 12, 2026 22:14
@codyrancher codyrancher marked this pull request as ready for review May 12, 2026 22:15
Comment thread shell/components/form/Security.vue Outdated

if (securityContext.fsGroup === '') {
// Drop empty values so we don't send a string for int64 fields.
if (securityContext.fsGroup === '' || securityContext.fsGroup === null) {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

could this also be undefined by any chance?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, it looks like it could be. I went ahead and put an explicit check in for undefined as well. We could combine the checks into a simpler expression but I thought being explicit would make the intentions more clear.

The parent security context object may not include these fields at all,
leaving them as undefined after the spread in data(). The existing
empty-string and null guards did not cover this case.
Copy link
Copy Markdown
Member

@torchiaf torchiaf left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@codyrancher codyrancher merged commit 6fbd103 into rancher:master May 27, 2026
137 of 142 checks passed
@codyrancher codyrancher deleted the issue-9601 branch May 27, 2026 14:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Removing Runas User ID causes validation error on save

2 participants