Fix runAsUser and fsGroup validation error when clearing fields#17450
Merged
Conversation
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
torchiaf
reviewed
May 20, 2026
|
|
||
| if (securityContext.fsGroup === '') { | ||
| // Drop empty values so we don't send a string for int64 fields. | ||
| if (securityContext.fsGroup === '' || securityContext.fsGroup === null) { |
Member
There was a problem hiding this comment.
could this also be undefined by any chance?
Member
Author
There was a problem hiding this comment.
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes #9601
Occurred changes and/or fixed issues
Clearing
runAsUserorfsGroupinputs sent""ornullinstead of omitting the key.Technical notes summary
null,""andundefinedvalues forfsGroup/runAsUserinSecurity.vue'supdate()before emittype="number" min="0"torunAsUserinput (was missing); addmin="0"tofsGroupinputAreas or cases that should be tested
runAsUserset, clear the field, save - should succeedfsGroupon the pod security context tabAreas which could experience regressions
SecuritycomponentScreenshot/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
Admin,Standard UserandUser Base