Skip to content

ParentReferencesSelect can't distinguish two Gateways with the same name in different namespaces — always selects the first #822

Description

@Anton-Fil

Description:

In src/utils/ParentReferencesSelect.tsx, each Gateway FormSelectOption shows name (namespace) in its label, but its value is only gateway.metadata.name. So two Gateways that share a name in different namespaces appear as two visually distinct rows, yet carry the same underlying value.

Because the option value is not unique:

  • FormSelect.onChange receives only the name and can't tell which row was clicked;
  • updateParentReference resolves it with availableGateways.find((gw) => gw.metadata.name === value), which always returns the first match — so the wrong namespace is written to the HTTPRoute's parentRef;
  • on re-render, value={parentRef.gatewayName} (name only) matches the first option with that value, so the dropdown visually snaps the selection back to the first Gateway.

Steps to reproduce:

  1. Create two Gateways with the same name in two different namespaces.
  2. Open Create (or Edit) HTTPRoute → add a parent reference → open the Gateway dropdown.
  3. You see two rows, e.g. gw (ns-a) and gw (ns-b).
  4. Select the second one (gw (ns-b)).
  5. Observed: the form resolves to the first Gateway (gw (ns-a)) — its namespace is written to the parentRef, and the dropdown shows the first entry as selected. You cannot actually pick the second Gateway.

Expected: Each row is uniquely selectable; selecting gw (ns-b) keeps gw (ns-b) selected and writes ns-b to the parentRef.

Proposed fix:
Use ${namespace}/${name} as both the option value and the resolution/selection key (and parse it back on change), following the pattern already used in src/components/gateway/GatewaySelect.tsx. Verify standalone Create/Edit HTTPRoute e2e still passes.

Context: Pre-existing defect (predates #795), flagged by CodeRabbit on the #795 PR. Deferred from that PR because the fix touches the standalone Create HTTPRoute form, which #795 promised to leave behaviorally unchanged.

Screen.Recording.2026-09-01.at.15.33.50.mov

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingtriage/needs-triageNew issue, awaiting maintainer review

    Type

    No type

    Projects

    • Status
      No status

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions