Skip to content

Fix null Explanations causing regressed tests modal crash#3605

Open
redhat-chai-bot wants to merge 1 commit into
openshift:mainfrom
redhat-chai-bot:06101647-bot-changes
Open

Fix null Explanations causing regressed tests modal crash#3605
redhat-chai-bot wants to merge 1 commit into
openshift:mainfrom
redhat-chai-bot:06101647-bot-changes

Conversation

@redhat-chai-bot

@redhat-chai-bot redhat-chai-bot commented Jun 10, 2026

Copy link
Copy Markdown
Contributor

Problem

Opening the regressed tests modal on the component readiness page crashes with:

can't access property "length", explanations is null

in CompSeverityIcon.

Root Cause

TestComparison structs are created with a nil Explanations slice in component_report.go and test_details.go. Several code paths in assessComponentStatus / buildFisherExactTestStats never append to Explanations (e.g. the "no regression" branch), so it stays nil. Go serializes nil slices as JSON null.

On the frontend, CompSeverityIcon.js checked explanations !== undefined which does not catch null, so null.length throws a TypeError and crashes the modal.

Fix

  1. Initialize Explanations: []string{} at both TestComparison creation sites so Go serializes it as [] instead of null.
  2. Add a defensive != null check in CompSeverityIcon.js (JS loose equality != null catches both null and undefined).

Files Changed

  • pkg/api/componentreadiness/component_report.go — initialize Explanations to empty slice
  • pkg/api/componentreadiness/test_details.go — initialize Explanations to empty slice
  • sippy-ng/src/component_readiness/CompSeverityIcon.js — use != null instead of !== undefined

Closes: TRT-2660

Summary by CodeRabbit

  • Bug Fixes
    • Fixed component explanations and tooltips to display reliably by ensuring proper initialization and validation of explanation data.

Initialize Explanations slice to []string{} instead of nil at both
TestComparison creation sites (component_report.go, test_details.go).
Go serializes nil slices as JSON null, which crashes the
CompSeverityIcon component when it tries to access explanations.length.

Also add a defensive != null check in CompSeverityIcon.js to guard
against any future nil serialization.

Closes: TRT-2660
@openshift-merge-bot

Copy link
Copy Markdown
Contributor

Pipeline controller notification
This repo is configured to use the pipeline controller. Second-stage tests will be triggered either automatically or after lgtm label is added, depending on the repository configuration. The pipeline controller will automatically detect which contexts are required and will utilize /test Prow commands to trigger the second stage.

For optional jobs, comment /test ? to see a list of all defined jobs. To trigger manually all jobs from second stage use /pipeline required command.

This repository is configured in: automatic mode

@openshift-ci openshift-ci Bot added the ready-for-human-review Indicates a PR has been reviewed by automated tools and is ready for human review label Jun 10, 2026
@coderabbitai

coderabbitai Bot commented Jun 10, 2026

Copy link
Copy Markdown
Contributor

Walkthrough

This PR initializes the Explanations field to a non-nil empty array in two backend functions that construct test comparison reports, ensuring the field is never left uninitialized. The frontend component is updated to check for non-null values instead of undefined, properly detecting the initialized field.

Changes

Explanations Field Initialization

Layer / File(s) Summary
Initialize and handle Explanations field
pkg/api/componentreadiness/component_report.go, pkg/api/componentreadiness/test_details.go, sippy-ng/src/component_readiness/CompSeverityIcon.js
Backend code explicitly initializes Explanations to an empty slice in generateComponentTestReport and internalGenerateTestDetailsReport. Frontend component updates the null-check from undefined to != null to properly detect the initialized non-nil field.

Estimated code review effort

🎯 1 (Trivial) | ⏱️ ~3 minutes

🚥 Pre-merge checks | ✅ 19 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Test Coverage For New Features ⚠️ Warning Bug fix lacks regression test coverage. CompSeverityIcon.js null check fix has no test file, and Go initialization changes have no tests verifying JSON serialization behavior. Add CompSeverityIcon.test.js with tests for null/undefined/empty explanations scenarios; add Go test verifying JSON serialization produces empty array not null.
✅ Passed checks (19 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately summarizes the main fix: initializing null Explanations to prevent a crash in the regressed tests modal.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Go Error Handling ✅ Passed PR changes initialize struct fields (Explanations: []string{}), not error handling. Existing code properly checks errors, wraps with context, avoids panic and error ignoring.
Sql Injection Prevention ✅ Passed SQL Injection Prevention check is not applicable: PR modifies only struct initialization and frontend null checks, with no SQL query construction or database operations.
Excessive Css In React Should Use Styles ✅ Passed CompSeverityIcon.js uses withStyles() HOC (Material-UI best practice) for badge styling, not excessive inline styles. No inline style props detected.
Single Responsibility And Clear Naming ✅ Passed PR changes preserve single responsibility and clear naming: no methods, structs, or packages renamed; function names remain action-oriented; no generic names introduced; struct organization unchanged.
Stable And Deterministic Test Names ✅ Passed No Ginkgo tests are added or modified in this PR. The check applies only to Ginkgo test names; it is not applicable here.
Test Structure And Quality ✅ Passed No Ginkgo test code present in PR. Repository uses standard Go testing (testing.T), not Ginkgo. Custom check is not applicable.
Microshift Test Compatibility ✅ Passed PR does not add any Ginkgo e2e tests; it only modifies non-test source files (backend Go code and frontend React component) to fix a null Explanations bug.
Single Node Openshift (Sno) Test Compatibility ✅ Passed No Ginkgo e2e tests are added in this PR. Changes are limited to backend API code and frontend component logic for a bug fix; the SNO compatibility check is not applicable.
Topology-Aware Scheduling Compatibility ✅ Passed PR changes are limited to data structure initialization and frontend null-guard logic; no deployment manifests, operator code, controllers, or scheduling constraints involved.
Ote Binary Stdout Contract ✅ Passed Check not applicable. This modifies Sippy library/frontend code, not an OTE binary. OTE Stdout Contract only applies to OpenShift Tests Extension binaries.
Ipv6 And Disconnected Network Test Compatibility ✅ Passed No Ginkgo e2e tests are added in this PR. The changes are to Go backend API packages and a React UI component, not test code. The check is not applicable.
No-Weak-Crypto ✅ Passed PR contains no cryptographic operations, weak crypto algorithms, custom crypto, or non-constant-time secret comparisons. Changes only fix null safety in component readiness.
Container-Privileges ✅ Passed PR changes Go and JavaScript code only. No Kubernetes manifests or container configurations with privilege settings are present or modified.
No-Sensitive-Data-In-Logs ✅ Passed No sensitive data (passwords, tokens, API keys, PII, session IDs, hostnames) is exposed in logging. Changes initialize empty slices and add null-checks; no new logging is introduced.

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

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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 openshift-ci Bot requested review from deepsm007 and xueqzhan June 10, 2026 16:49
@openshift-ci

openshift-ci Bot commented Jun 10, 2026

Copy link
Copy Markdown
Contributor

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: redhat-chai-bot
Once this PR has been reviewed and has the lgtm label, please assign petr-muller 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

@openshift-ci openshift-ci Bot added the needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. label Jun 10, 2026
@openshift-ci

openshift-ci Bot commented Jun 10, 2026

Copy link
Copy Markdown
Contributor

Hi @redhat-chai-bot. Thanks for your PR.

I'm waiting for a openshift member to verify that this patch is reasonable to test. If it is, they should reply with /ok-to-test on its own line. Until that is done, I will not automatically test new commits in this PR, but the usual testing commands by org members will still work.

Tip

We noticed you've done this a few times! Consider joining the org to skip this step and gain /lgtm and other bot rights. We recommend asking approvers on your previous PRs to sponsor you.

Once the patch is verified, the new status will be reflected by the ok-to-test label.

I understand the commands that are listed here.

Details

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 kubernetes-sigs/prow repository.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@sippy-ng/src/component_readiness/CompSeverityIcon.js`:
- Around line 22-24: Add a regression test for CompSeverityIcon that verifies
the component safely handles explanations being null, undefined, and an empty
array: render the component with explanations=null, explanations=undefined, and
explanations=[], assert that rendering does not throw, that no exception occurs
in the tooltip generation code path (the logic around the explanations guard and
toolTip), and that the tooltip fallback/placeholder is shown when explanations
is falsy or empty; add the tests to the existing test suite for this component
so they fail before the guard fix and pass afterward.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository YAML (base), Central YAML (inherited)

Review profile: CHILL

Plan: Enterprise

Run ID: 031c58b8-7c51-4b2d-a559-f36e69a128d5

📥 Commits

Reviewing files that changed from the base of the PR and between f776645 and fc3322a.

📒 Files selected for processing (3)
  • pkg/api/componentreadiness/component_report.go
  • pkg/api/componentreadiness/test_details.go
  • sippy-ng/src/component_readiness/CompSeverityIcon.js

Comment on lines +22 to 24
if (explanations != null && explanations.length > 0) {
toolTip = explanations.join(' ')
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟠 Major | ⚡ Quick win

Add a regression test for the null explanations crash path.

The Line 22 guard is correct, but this bug fix should be locked with a regression test (e.g., null, undefined, and [] explanations render without throwing and tooltip fallback still works).

As per coding guidelines, “bug fixes should include a regression test that fails without the fix.”

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@sippy-ng/src/component_readiness/CompSeverityIcon.js` around lines 22 - 24,
Add a regression test for CompSeverityIcon that verifies the component safely
handles explanations being null, undefined, and an empty array: render the
component with explanations=null, explanations=undefined, and explanations=[],
assert that rendering does not throw, that no exception occurs in the tooltip
generation code path (the logic around the explanations guard and toolTip), and
that the tooltip fallback/placeholder is shown when explanations is falsy or
empty; add the tests to the existing test suite for this component so they fail
before the guard fix and pass afterward.

Source: Coding guidelines

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

Labels

needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. ready-for-human-review Indicates a PR has been reviewed by automated tools and is ready for human review

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant