Fix Ingress form editor to handle backend.service.port.name#17631
Merged
Conversation
The form editor only read/wrote backend.service.port.number, leaving the port field blank when an Ingress used port.name instead. Now both port.name and port.number are supported for reading, writing, validation, and port dropdown options. Fixes rancher#17105
- Fix Number.parseInt fallthrough when port is 0 (falsy but valid parse) - Split portNumberOrName into portRequired and portRange validators - Handle both scalar (component-level) and object (mixin-level) inputs - Restore required asterisk on DefaultBackend port fields - Add unit tests for port parsing, portRequired, and portRange
aalves08
requested changes
May 18, 2026
Member
aalves08
left a comment
There was a problem hiding this comment.
There's a scenario where this is failing @codyrancher :
- User edits an Ingress, goes to the Default Backend tab
- Selects a service and picks port http (a named port) from the dropdown
- The DefaultBackend.vue update() method correctly detects that "http" is a string and writes it to service.port.name — leaving service.port.number empty
- User clicks Save
- willSave() fires. It reads service.port.number — which is empty/undefined because the port was stored under service.port.name
- !servicePort evaluates to true
- The hook concludes "the default backend is incomplete" and runs set(this.value.spec, path, null), which deletes the entire default backend
- The Ingress is saved without the default backend the user just configured
willSave() only checked servicePortPath (port.number), missing backends that store the port under servicePortNamePath (port.name).
Default backend validation rules now only enforce required checks when a service is actually selected. Selecting "None" skips validation so the user can save, and willSave() cleans up the empty backend object.
Member
Author
That was a good find. I had to make some changes to validation to get the field requirements correct but it should be fixed now. |
aalves08
approved these changes
May 20, 2026
Member
aalves08
left a comment
There was a problem hiding this comment.
Sorry for the delay and thanks for the fix! LGTM!
Member
Author
@aalves08 No worries, you're way more on top of things than I am. Thanks for the review! |
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 #17105
Occurred changes and/or fixed issues
The Ingress form editor only read/wrote
backend.service.port.number, so Ingresses usingbackend.service.port.nameshowed a blank port field. This adds support for both across reading, writing, validation, and the port dropdown.Technical notes summary
servicePortNamePathgetter to the Ingress modelfindAndMapServiceTargetsnow includes port names in dropdown optionsRulePath.vueandDefaultBackend.vueread from bothport.numberandport.name, write to the correct path based on typeportNumberOrNamevalidator withportRequired(presence check) andportRange(1-65535), both handling scalar and object inputsNumber.parseIntfallthrough when port value is falsy (e.g. 0)Reproduction resources
Apply these to create a Service with named ports and two Ingresses (one using
port.name, one usingport.number):The bug: editing
ingress-port-namein the form editor shows a blank port field. Editingingress-port-numberworks fine.Areas or cases that should be tested
ingress-port-nameand verify the port field shows "http"ingress-port-numberand verify the port field shows "80"test-web-service, and verify both port numbers and names appear in the dropdownport.name; same forport.numberAreas which could experience regressions
Screenshot/Video
Before (bug): YAML shows
port.name: httpis defined, but the form editor's port field is empty (red highlight)before.webm
After (fix): port name "http" is correctly displayed in the form (green highlight), save succeeds
after.webm
Checklist
Admin,Standard UserandUser Base