Skip to content

Conversation

@upalatucci
Copy link
Member

@upalatucci upalatucci commented Feb 13, 2026

📝 Description

Fixes a crash in the SCSI persistent reservation section of the Virtualization Settings page (Cluster tab).

The error Cannot read properties of null (reading 'metadata') occurs because hyperConverge can be null even after loading completes (e.g., when the HyperConverged resource list is empty). When the switch is toggled, onChange passes the null resource to k8sPatch, which tries to access resource.metadata.namespace and crashes.

Changes:

  • Add a null guard (if (!hyperConverge) return) in the onChange handler to prevent calling k8sPatch with a null resource
  • Disable the switch when hyperConverge is null (isDisabled={!hyperLoaded || !hyperConverge}) so it cannot be toggled without a valid resource

Jira: https://issues.redhat.com/browse/CNV-79748

🎥 Demo

Before: Error banner shown in the SCSI persistent reservation section — "Cannot read properties of null (reading 'metadata')"

After: Switch is properly disabled when HyperConverged resource is unavailable, no crash

Made with Cursor

Summary by CodeRabbit

  • Bug Fixes
    • Fixed handling of persistent reservation settings to properly validate state before processing changes and updated disabled state logic for improved reliability.

…tings

Add null guard for hyperConverge before calling k8sPatch and disable
the switch when HyperConverged resource is not available to prevent
"Cannot read properties of null (reading 'metadata')" error.

Co-authored-by: Cursor <[email protected]>
@openshift-ci-robot
Copy link
Collaborator

openshift-ci-robot commented Feb 13, 2026

@upalatucci: This pull request references CNV-79748 which is a valid jira issue.

Warning: The referenced jira issue has an invalid target version for the target branch this PR targets: expected the bug to target the "4.22.0" version, but no target version was set.

Details

In response to this:

📝 Description

Fixes a crash in the SCSI persistent reservation section of the Virtualization Settings page (Cluster tab).

The error Cannot read properties of null (reading 'metadata') occurs because hyperConverge can be null even after loading completes (e.g., when the HyperConverged resource list is empty). When the switch is toggled, onChange passes the null resource to k8sPatch, which tries to access resource.metadata.namespace and crashes.

Changes:

  • Add a null guard (if (!hyperConverge) return) in the onChange handler to prevent calling k8sPatch with a null resource
  • Disable the switch when hyperConverge is null (isDisabled={!hyperLoaded || !hyperConverge}) so it cannot be toggled without a valid resource

Jira: https://issues.redhat.com/browse/CNV-79748

🎥 Demo

Before: Error banner shown in the SCSI persistent reservation section — "Cannot read properties of null (reading 'metadata')"

After: Switch is properly disabled when HyperConverged resource is unavailable, no crash

Made with Cursor

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the openshift-eng/jira-lifecycle-plugin repository.

@openshift-ci openshift-ci bot requested review from avivtur and batyana February 13, 2026 10:31
@openshift-ci
Copy link
Contributor

openshift-ci bot commented Feb 13, 2026

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: upalatucci

The full list of commands accepted by this bot can be found here.

The pull request process is described 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

@openshift-ci openshift-ci bot added the approved This issue is something we want to fix label Feb 13, 2026
@coderabbitai
Copy link

coderabbitai bot commented Feb 13, 2026

📝 Walkthrough

Walkthrough

Added defensive null checks to the PersistentReservationSection component. An early return guard was introduced in the onChange handler, and the disabled state condition was extended to verify hyperConverge is truthy before proceeding with state updates.

Changes

Cohort / File(s) Summary
Defensive Guard Checks
src/views/clusteroverview/SettingsTab/ClusterTab/components/PersistentReservationSection/PersistentReservationSection.tsx
Added early guard in onChange handler to return if hyperConverge is falsy; extended isDisabled condition to require hyperConverge presence (isDisabled: !hyperLoaded || !hyperConverge).

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~8 minutes

Suggested labels

lgtm, approved

Suggested reviewers

  • aviavissar
  • adamviktora
  • avivtur
🚥 Pre-merge checks | ✅ 4
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly describes the main fix: preventing a null metadata crash in SCSI persistent reservation settings, which aligns with the code changes.
Description check ✅ Passed The description includes all required template sections with comprehensive details about the bug, root cause, changes made, and visual demo expectations.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Merge Conflict Detection ✅ Passed ✅ No merge conflicts detected when merging into main

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

No actionable comments were generated in the recent review. 🎉


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@openshift-ci-robot
Copy link
Collaborator

openshift-ci-robot commented Feb 13, 2026

@upalatucci: This pull request references CNV-79748 which is a valid jira issue.

Warning: The referenced jira issue has an invalid target version for the target branch this PR targets: expected the bug to target the "4.22.0" version, but no target version was set.

Details

In response to this:

📝 Description

Fixes a crash in the SCSI persistent reservation section of the Virtualization Settings page (Cluster tab).

The error Cannot read properties of null (reading 'metadata') occurs because hyperConverge can be null even after loading completes (e.g., when the HyperConverged resource list is empty). When the switch is toggled, onChange passes the null resource to k8sPatch, which tries to access resource.metadata.namespace and crashes.

Changes:

  • Add a null guard (if (!hyperConverge) return) in the onChange handler to prevent calling k8sPatch with a null resource
  • Disable the switch when hyperConverge is null (isDisabled={!hyperLoaded || !hyperConverge}) so it cannot be toggled without a valid resource

Jira: https://issues.redhat.com/browse/CNV-79748

🎥 Demo

Before: Error banner shown in the SCSI persistent reservation section — "Cannot read properties of null (reading 'metadata')"

After: Switch is properly disabled when HyperConverged resource is unavailable, no crash

Made with Cursor

Summary by CodeRabbit

  • Bug Fixes
  • Fixed handling of persistent reservation settings to properly validate state before processing changes and updated disabled state logic for improved reliability.

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the openshift-eng/jira-lifecycle-plugin repository.

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

Labels

approved This issue is something we want to fix jira/valid-reference

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants