Skip to content

fix: prevent crash when cluster name is undefined in getDetailsLink#4403

Open
Sagar-6203620715 wants to merge 2 commits intokubernetes-sigs:mainfrom
Sagar-6203620715:fix-link-undefined-name
Open

fix: prevent crash when cluster name is undefined in getDetailsLink#4403
Sagar-6203620715 wants to merge 2 commits intokubernetes-sigs:mainfrom
Sagar-6203620715:fix-link-undefined-name

Conversation

@Sagar-6203620715
Copy link
Contributor

Summary

This PR fixes a crash that occurs when accessing the Clusters page for clusters with undefined metadata.name (e.g., AWS EKS clusters with ARN-style names containing special characters like arn:aws:eks:eu-west-1:XXXXXXXXXXXX:cluster--xxx-xxxxxx-xxxx).

Related Issue

Fixes #4304

Changes

  • Added null check in KubeObject.getDetailsLink() before generating route URLs
  • Returns empty string with console warning when object name is undefined
  • Prevents TypeError: Expected "name" to be defined from react-router's generatePath()

Root Cause

The crash occurred because getDetailsLink() called getName() which returned undefined for certain cluster configurations. This undefined value was then passed to createRouteURL()generatePath(), which expects all route parameters to be defined, causing the application to crash.

Steps to Test

  1. Add a cluster with an ARN-style name (or any cluster where metadata.name is undefined)
  2. Navigate to the Clusters page (/c/:cluster/cluster)
  3. Verify the page loads without crashing
  4. Check browser console for warning message about undefined cluster name
  5. Confirm other clusters with valid names still generate proper detail links

Notes for the Reviewer

  • The fix is defensive at the getDetailsLink() layer rather than modifying getName() to preserve its current behavior for other use cases
  • Console warning provides debugging context (kind, cluster, namespace) to help identify problematic resources
  • Returning empty string prevents malformed URLs while allowing calling code to handle gracefully

Add null check in KubeObject.getDetailsLink() to handle cases where
metadata.name is undefined (e.g., AWS EKS clusters with ARN formats).
Returns empty string with warning instead of crashing
@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is NOT APPROVED

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

@k8s-ci-robot k8s-ci-robot added size/S Denotes a PR that changes 10-29 lines, ignoring generated files. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. labels Jan 20, 2026
Copy link
Contributor

@skoeva skoeva left a comment

Choose a reason for hiding this comment

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

Hi, would you mind updating the PR/commit title to match our commit guidelines?

Copy link
Contributor

@vyncent-t vyncent-t left a comment

Choose a reason for hiding this comment

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

Looks good, wondering if this could be refined

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR fixes a crash that occurs when displaying clusters with undefined metadata.name (specifically AWS EKS clusters with ARN-style names). The crash happened because getDetailsLink() passed undefined to generatePath(), which requires all route parameters to be defined.

Changes:

  • Added null check in KubeObject.getDetailsLink() to validate object name before generating route URLs
  • Returns empty string with console warning when object name is undefined instead of crashing
  • Prevents TypeError: Expected "name" to be defined from react-router's generatePath()

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@Sagar-6203620715
Copy link
Contributor Author

HI @vyncent-t .Seems that the copilot review approves it too.
I have thoroughly tested the fix. Please approve the workflow for further tests.

Ready for review/merge!

Copy link
Contributor

@illume illume left a comment

Choose a reason for hiding this comment

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

Thanks for this.

@Sagar-6203620715 is there a way we can have a link for these ones as well? This would make it so the user can not click on them.

Please check the other commit messages to see how they look and checkout the commit guidelines docs.

frontend: KubeObject: Prevent crash when cluster name is undefined in getDetailsLink

Copy link
Contributor

@vyncent-t vyncent-t left a comment

Choose a reason for hiding this comment

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

This branch is behind, please update and rebase with the newest changes 👍

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

Labels

cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. size/S Denotes a PR that changes 10-29 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Crash Report: Expected "name" to be defined

5 participants