-
Notifications
You must be signed in to change notification settings - Fork 60
Fix: Cannot read properties of undefined (reading 'conditions') #483
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
There was a problem hiding this 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 runtime error where the application crashes when trying to access the conditions property of an undefined status object in cert-manager resources. The fix adds optional chaining operators to safely handle cases where Kubernetes resources may not have a status field yet (e.g., when first created or in certain error states).
Changes:
- Added optional chaining to
statusandconditionsproperty accesses in CertificateRequest and Certificate classes - Added optional chaining to status property accesses in the CertificateRequest detail view component
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| cert-manager/src/resources/certificateRequest.ts | Added optional chaining to approved, denied, and ready getters when accessing status?.conditions |
| cert-manager/src/resources/certificate.ts | Added optional chaining to ready getter when accessing status?.conditions |
| cert-manager/src/components/certificateRequests/Detail.tsx | Added optional chaining when accessing status?.ca and status?.conditions in the detail view |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
I have fixed the linting error, this PR should be ready to be merged :) |
|
@illume Please review this PR. |
|
@mudit06mah thanks. For the commit message, something closer to this:
|
illume
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🎉 thanks!
(Apart from commit message lgtm)
…eRequest.status.conditions being optional Signed-off-by: mudit06mah <mudit06maheshwari@gmail.com>
|
@illume I have changed the commit message :) |
|
@illume Can you Please review this again? |
Summary:
Fixes undefined error by adding optional chaining operator
Issue:
Fixes Issue: #482 (Originally present in the Parent Repo: kubernetes-sigs/headlamp#4358)
Changes:
Added optional chaining operator while accessing
CertifcateRequest.statusandCertifcateRequest.status.conditionsto not cause an error if undefined.