Skip to content

Conversation

@mudit06mah
Copy link

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.status and CertifcateRequest.status.conditions to not cause an error if undefined.

Copy link

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 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 status and conditions property 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.

@mudit06mah
Copy link
Author

I have fixed the linting error, this PR should be ready to be merged :)

@mudit06mah
Copy link
Author

@illume Please review this PR.

@illume
Copy link
Contributor

illume commented Jan 25, 2026

@mudit06mah thanks.

For the commit message, something closer to this:

cert-manager: certificateRequests: Fix undefined error with CertifcateRequest.status.conditions being optional

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!

(Apart from commit message lgtm)

…eRequest.status.conditions being optional

Signed-off-by: mudit06mah <mudit06maheshwari@gmail.com>
@mudit06mah
Copy link
Author

@illume I have changed the commit message :)

@mudit06mah
Copy link
Author

@illume Can you Please review this again?

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants