fix: prevent crash when cluster name is undefined in getDetailsLink#4403
fix: prevent crash when cluster name is undefined in getDetailsLink#4403Sagar-6203620715 wants to merge 2 commits intokubernetes-sigs:mainfrom
Conversation
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
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: Sagar-6203620715 The full list of commands accepted by this bot can be found here. DetailsNeeds approval from an approver in each of these files:Approvers can indicate their approval by writing |
skoeva
left a comment
There was a problem hiding this comment.
Hi, would you mind updating the PR/commit title to match our commit guidelines?
vyncent-t
left a comment
There was a problem hiding this comment.
Looks good, wondering if this could be refined
There was a problem hiding this comment.
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 definedfrom react-router'sgeneratePath()
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
HI @vyncent-t .Seems that the copilot review approves it too. Ready for review/merge! |
There was a problem hiding this comment.
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
vyncent-t
left a comment
There was a problem hiding this comment.
This branch is behind, please update and rebase with the newest changes 👍
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 likearn:aws:eks:eu-west-1:XXXXXXXXXXXX:cluster--xxx-xxxxxx-xxxx).Related Issue
Fixes #4304
Changes
KubeObject.getDetailsLink()before generating route URLsTypeError: Expected "name" to be definedfromreact-router'sgeneratePath()Root Cause
The crash occurred because
getDetailsLink()calledgetName()which returnedundefinedfor certain cluster configurations. This undefined value was then passed tocreateRouteURL()→generatePath(), which expects all route parameters to be defined, causing the application to crash.Steps to Test
metadata.nameis undefined)/c/:cluster/cluster)Notes for the Reviewer
getDetailsLink()layer rather than modifyinggetName()to preserve its current behavior for other use cases