Skip to content

OCPBUGS-85013: Fix Topology page TypeError when resource is null - #17071

Open
platex-rehor-bot wants to merge 2 commits into
openshift:mainfrom
platex-rehor-bot:bot/OCPBUGS-85013
Open

OCPBUGS-85013: Fix Topology page TypeError when resource is null#17071
platex-rehor-bot wants to merge 2 commits into
openshift:mainfrom
platex-rehor-bot:bot/OCPBUGS-85013

Conversation

@platex-rehor-bot

@platex-rehor-bot platex-rehor-bot commented Aug 21, 2026

Copy link
Copy Markdown
Contributor

Analysis / Root cause:

The Topology view crashes with TypeError: can't access property kind, e is null when rendering nodes whose resource object has not yet loaded or is unavailable. This occurs when installing Helm charts from the Developer Catalog — the Helm release group node may not have a matching Secret, causing getTopologyResourceObject() to return null. Several topology components then pass this null to referenceFor(), which destructures { kind, apiVersion } from its argument, producing the TypeError.

The root cause is in helm-data-transformer.ts line 89 where resources.obj is explicitly set to null when no matching Secret exists:

obj: secret ? { ...secret, kind, apiVersion } : null,

Multiple downstream consumers (WorkloadNode, BaseNode, BindableNode, withEditReviewAccess, OdcBaseNode, getResourceKind) access .kind or call referenceFor() on the result without null guards.

Solution description:

Added null guards using optional chaining (?.) and conditional expressions across all affected call sites in the topology package:

  • WorkloadNode.tsx: resource?.kind and resource?.metadata?.namespace instead of direct access
  • BaseNode.tsx: Guard referenceFor(resourceObj) and resourceObj.metadata.* with null checks
  • BindableNode.tsx: Guard referenceFor(resourceObj) with null check
  • withEditReviewAccess.tsx: Guard referenceFor(resourceObj), resourceModel.*, and resourceObj.metadata.*
  • OdcBaseNode.ts: Guard referenceFor(this.resource) when resource is undefined
  • topology-utils.ts: Guard referenceFor() result in getResourceKind utility

All changes are minimal defensive additions — no logic changes, no new behavior when resources are present.

Screenshots / screen recording:

Test setup:
Install a Helm chart from the Developer Catalog (e.g. Edge Manager) and navigate to the Topology view while resources are still initializing.

Test cases:

  • Install a Helm chart from Developer Catalog → Topology view renders without crash
  • Navigate to Topology view with existing Helm releases → nodes render correctly
  • Topology view for non-Helm workloads still works correctly
  • Collapsed and expanded Helm release group nodes render without error

Browser conformance:

  • Chrome
  • Firefox
  • Safari (or Epiphany on Linux)

Additional info:
Jira: https://redhat.atlassian.net/browse/OCPBUGS-85013

Reviewers and assignees:

Summary by CodeRabbit

  • Bug Fixes
    • Improved topology views to handle missing or incomplete resource information safely.
    • Prevented errors when resource metadata, kinds, namespaces, or models are unavailable.
    • Improved access review handling when resource details are incomplete.

The Topology view crashes with "can't access property kind, e is null"
when rendering nodes whose resource object has not yet loaded or is
unavailable (e.g. Helm release group nodes without a matching Secret).

getTopologyResourceObject() can return null, but several components
pass its result directly to referenceFor() which destructures {kind}
from the argument, causing a TypeError on null.

Add null guards with optional chaining across all affected call sites:
WorkloadNode, BaseNode, BindableNode, withEditReviewAccess,
OdcBaseNode, and getResourceKind utility.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@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: LGTM mode

@openshift-ci-robot openshift-ci-robot added jira/severity-moderate Referenced Jira bug's severity is moderate for the branch this PR is targeting. jira/valid-reference Indicates that this PR references a valid Jira ticket of any type. jira/invalid-bug Indicates that a referenced Jira bug is invalid for the branch this PR is targeting. labels Aug 21, 2026
@openshift-ci-robot

Copy link
Copy Markdown
Contributor

@platex-rehor-bot: This pull request references Jira Issue OCPBUGS-85013, which is invalid:

  • expected the bug to target the "5.1.0" version, but no target version was set

Comment /jira refresh to re-evaluate validity if changes to the Jira bug are made, or edit the title of this pull request to link to a different bug.

The bug has been updated to refer to the pull request using the external bug tracker.

Details

In response to this:

Analysis / Root cause:

The Topology view crashes with TypeError: can't access property kind, e is null when rendering nodes whose resource object has not yet loaded or is unavailable. This occurs when installing Helm charts from the Developer Catalog — the Helm release group node may not have a matching Secret, causing getTopologyResourceObject() to return null. Several topology components then pass this null to referenceFor(), which destructures { kind, apiVersion } from its argument, producing the TypeError.

The root cause is in helm-data-transformer.ts line 89 where resources.obj is explicitly set to null when no matching Secret exists:

obj: secret ? { ...secret, kind, apiVersion } : null,

Multiple downstream consumers (WorkloadNode, BaseNode, BindableNode, withEditReviewAccess, OdcBaseNode, getResourceKind) access .kind or call referenceFor() on the result without null guards.

Solution description:

Added null guards using optional chaining (?.) and conditional expressions across all affected call sites in the topology package:

  • WorkloadNode.tsx: resource?.kind and resource?.metadata?.namespace instead of direct access
  • BaseNode.tsx: Guard referenceFor(resourceObj) and resourceObj.metadata.* with null checks
  • BindableNode.tsx: Guard referenceFor(resourceObj) with null check
  • withEditReviewAccess.tsx: Guard referenceFor(resourceObj), resourceModel.*, and resourceObj.metadata.*
  • OdcBaseNode.ts: Guard referenceFor(this.resource) when resource is undefined
  • topology-utils.ts: Guard referenceFor() result in getResourceKind utility

All changes are minimal defensive additions — no logic changes, no new behavior when resources are present.

Screenshots / screen recording:

Test setup:
Install a Helm chart from the Developer Catalog (e.g. Edge Manager) and navigate to the Topology view while resources are still initializing.

Test cases:

  • Install a Helm chart from Developer Catalog → Topology view renders without crash
  • Navigate to Topology view with existing Helm releases → nodes render correctly
  • Topology view for non-Helm workloads still works correctly
  • Collapsed and expanded Helm release group nodes render without error

Browser conformance:

  • Chrome
  • Firefox
  • Safari (or Epiphany on Linux)

Additional info:
Jira: https://redhat.atlassian.net/browse/OCPBUGS-85013

Reviewers and assignees:

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.

@coderabbitai

coderabbitai Bot commented Aug 21, 2026

Copy link
Copy Markdown
Contributor

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository: openshift/coderabbit/.coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: 5f0cb1f0-3969-4d9b-9187-a32b92d3b691

📥 Commits

Reviewing files that changed from the base of the PR and between 55f7fc2 and 7e9ae24.

📒 Files selected for processing (2)
  • frontend/packages/topology/src/utils/topology-utils.ts
  • frontend/packages/topology/src/utils/withEditReviewAccess.tsx

Included review availability: Your plan provides up to 2 included reviews per hour; 1 remains after this review.


Walkthrough

Topology resource resolution now handles missing resources and metadata without throwing. Graph nodes pass optional values to model lookup, access review, resource-kind resolution, and pod watching.

Changes

Topology resource safety

Layer / File(s) Summary
Guard shared resource resolution
frontend/packages/topology/src/elements/OdcBaseNode.ts, frontend/packages/topology/src/utils/topology-utils.ts, frontend/packages/topology/src/utils/withEditReviewAccess.tsx
Resource-kind and access-review resolution now avoid dereferencing absent resources or models.
Apply guards in graph nodes
frontend/packages/topology/src/components/graph-view/components/nodes/BaseNode.tsx, frontend/packages/topology/src/components/graph-view/components/nodes/BindableNode.tsx, frontend/packages/topology/src/components/graph-view/components/nodes/WorkloadNode.tsx
Graph nodes use conditional model lookup and optional resource metadata when resources are missing or incomplete.

Estimated code review effort: 2 (Simple) | ~10 minutes

Merge Risk: ⚪ Minimal · up to 7e9ae

This change adds defensive handling for unavailable topology resources to prevent a rendering crash without changing behavior when resources are present. No actionable merge-blocking risk remains beyond normal checks and review.

Suggested reviewers: sg00dwin, logonoff

🚥 Pre-merge checks | ✅ 15
✅ Passed checks (15 passed)
Check name Status Explanation
Description check ✅ Passed The description covers the root cause, solution, test setup, test cases, browser conformance, and additional issue information.
Title check ✅ Passed The title clearly identifies the Jira issue and the primary fix for the Topology page TypeError caused by a null resource.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check. Docstring coverage is scoped to functions touched by this diff. Analyzed 0 functions across 6 files.
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.
Stable And Deterministic Test Names ✅ Passed The PR changes six TypeScript source files only; the PR-wide diff adds no test files or It/Describe/Context/When declarations, so it introduces no unstable Ginkgo test name.
Test Structure And Quality ✅ Passed The complete PR changes only six frontend TypeScript files; no Ginkgo test paths, Ginkgo constructs, or test code were added or modified, so this check is inapplicable.
Microshift Test Compatibility ✅ Passed The PR changes only six frontend TypeScript files. It adds no Ginkgo e2e tests or It/Describe/Context/When blocks, so MicroShift test compatibility is not applicable.
Single Node Openshift (Sno) Test Compatibility ✅ Passed The PR changes only six TypeScript source files and adds no Ginkgo e2e tests or multi-node assumptions; the SNO test check is not applicable.
Topology-Aware Scheduling Compatibility ✅ Passed The PR changes only frontend topology TypeScript/TSX resource-null handling; the complete diff adds no manifests, controllers, replicas, affinity, topology spread, selectors, tolerations, or PDBs.
Ote Binary Stdout Contract ✅ Passed The PR changes only six frontend TypeScript topology files; the diff contains no OTE process-level code or stdout writes.
Ipv6 And Disconnected Network Test Compatibility ✅ Passed The full PR diff changes only six existing frontend TypeScript files and adds no Ginkgo e2e tests or IPv4/external-network test usage.
No-Weak-Crypto ✅ Passed The two-commit diff adds only null guards, optional chaining, and an undefined return path; it introduces no MD5, SHA1, DES, RC4, 3DES, Blowfish, ECB, custom crypto, or secret comparisons.
Container-Privileges ✅ Passed The PR changes only six TypeScript/TSX topology files; the diff contains no container/Kubernetes manifests or listed privilege settings.
No-Sensitive-Data-In-Logs ✅ Passed The PR diff adds only null guards and conditional resource access; it introduces no logging, telemetry, or output calls that could expose sensitive data.
✨ 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.

@platex-rehor-bot

Copy link
Copy Markdown
Contributor Author

/jira refresh

@openshift-ci-robot

Copy link
Copy Markdown
Contributor

@platex-rehor-bot: This pull request references Jira Issue OCPBUGS-85013, which is invalid:

  • expected the bug to target the "5.1.0" version, but no target version was set

Comment /jira refresh to re-evaluate validity if changes to the Jira bug are made, or edit the title of this pull request to link to a different bug.

Details

In response to this:

/jira refresh

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 added component/topology Related to topology needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. labels Aug 21, 2026
@openshift-ci

openshift-ci Bot commented Aug 21, 2026

Copy link
Copy Markdown
Contributor

Hi @platex-rehor-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.

@platex-rehor-bot

Copy link
Copy Markdown
Contributor Author

/jira refresh

@openshift-ci-robot openshift-ci-robot added jira/valid-bug Indicates that a referenced Jira bug is valid for the branch this PR is targeting. and removed jira/invalid-bug Indicates that a referenced Jira bug is invalid for the branch this PR is targeting. labels Aug 21, 2026
@openshift-ci-robot

Copy link
Copy Markdown
Contributor

@platex-rehor-bot: This pull request references Jira Issue OCPBUGS-85013, which is valid.

3 validation(s) were run on this bug
  • bug is open, matching expected state (open)
  • bug target version (5.1.0) matches configured target version for branch (5.1.0)
  • bug is in the state POST, which is one of the valid states (NEW, ASSIGNED, POST)

No GitHub users were found matching the public email listed for the QA contact in Jira (mniranja@redhat.com), skipping review request.

Details

In response to this:

/jira refresh

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.

@stefanonardo stefanonardo 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.

The defensive guards are a valid fix, but if other consumers are added in the future they'll hit the same trap

node instanceof OdcBaseNode
? (node as OdcBaseNode).getResourceKind()
: referenceFor(getTopologyResourceObject(node?.getData()));
export const getResourceKind = (node: Node): K8sResourceKindReference => {

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.

Suggested change
export const getResourceKind = (node: Node): K8sResourceKindReference => {
export const getResourceKind = (node: Node): K8sResourceKindReference | undefined => {

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Good catch — fixed in 7e9ae24. The return type now correctly reflects the | undefined possibility, matching the runtime behavior and the OdcBaseNode.getResourceKind() signature.

@@ -234,8 +234,8 @@ const WorkloadNode: FC<WorkloadNodeProps> = observer(({ element, ...rest }) => {
const resource = getTopologyResourceObject(element.getData());
const { podData, loadError, loaded } = usePodsWatcher(
resource,

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.

resource is of type K8sResourceKind but it's potentially null

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

You're right about the type gap. The GetTopologyResourceObject SDK type declares the return as K8sResourceKind, but the implementation can return null. Since updating the SDK type would be a breaking API change, we handle nullability at each call site with optional chaining (resource?.kind, resource?.metadata?.namespace). The usePodsWatcher hook also uses optional chaining internally, so null is handled gracefully at runtime — it skips watching when kind is undefined.

const resourceObj = getResource(props.element);
const resourceModel = modelFor(referenceFor(resourceObj));
const resourceModel = resourceObj ? modelFor(referenceFor(resourceObj)) : undefined;
const editAccess = useAccessReview({

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.

nit: with resourceModel being undefined, the RBAC request will fail, defaulting to setAllowed(true). So canEdit will be true for null resources. The server still enforces real access, but showing edit controls on unresolvable nodes seems wrong

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Great observation — fixed in 7e9ae24. When resourceObj is falsy, canEdit now defaults to false instead of relying on the RBAC check with undefined parameters. This prevents edit controls from appearing on unresolvable nodes.

- Fix getResourceKind return type to include undefined
- Prevent edit controls showing on unresolvable nodes by
  defaulting canEdit to false when resource is null

OCPBUGS-85013

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@jhadvig

jhadvig commented Aug 25, 2026

Copy link
Copy Markdown
Member

/ok-to-test

@openshift-ci openshift-ci Bot added ok-to-test Indicates a non-member PR verified by an org member that is safe to test. and removed needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. labels Aug 25, 2026
@stefanonardo

Copy link
Copy Markdown
Contributor

The defensive guards are a valid fix, but if other consumers are added in the future they'll hit the same trap

@platex-rehor-bot

Copy link
Copy Markdown
Contributor Author

/retest

@platex-rehor-bot

Copy link
Copy Markdown
Contributor Author

/retest-required

@platex-rehor-bot

Copy link
Copy Markdown
Contributor Author

Good point — you're right that defensive guards at each call site don't prevent future consumers from hitting the same null trap.

The root cause is that the SDK types GetTopologyResourceObject and GetResource (in topology-types.ts) declare non-nullable returns (K8sResourceKind / T), but the implementations can return null. TypeScript won't warn new consumers about the mismatch.

The proper fix is to update those SDK types to K8sResourceKind | null and T | null, which would make the compiler catch unhandled nulls everywhere. However, that change touches ~30 consumers across the topology, knative, and dev-console packages, so it's better scoped as a dedicated follow-up rather than bundled with this crash fix.

This PR addresses the immediate TypeError; a follow-up can close the type gap for good.

@platex-rehor-bot

Copy link
Copy Markdown
Contributor Author

/retest-required

@stefanonardo

Copy link
Copy Markdown
Contributor

/lgtm

@openshift-ci openshift-ci Bot added the lgtm Indicates that a PR is ready to be merged. label Aug 25, 2026
@openshift-merge-bot

Copy link
Copy Markdown
Contributor

Scheduling tests matching the pipeline_run_if_changed or not excluded by pipeline_skip_if_only_changed parameters:
/test e2e-gcp-console
/test e2e-playwright

@openshift-ci

openshift-ci Bot commented Aug 25, 2026

Copy link
Copy Markdown
Contributor

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: platex-rehor-bot, stefanonardo
Once this PR has been reviewed and has the lgtm label, please assign vojtechszocs 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

@jhadvig

jhadvig commented Aug 25, 2026

Copy link
Copy Markdown
Member

/test e2e-playwright-techpreview

@platex-rehor-bot

Copy link
Copy Markdown
Contributor Author

/test e2e-playwright

@openshift-ci

openshift-ci Bot commented Aug 25, 2026

Copy link
Copy Markdown
Contributor

@platex-rehor-bot: The following test failed, say /retest to rerun all failed tests or /retest-required to rerun all mandatory failed tests:

Test name Commit Details Required Rerun command
ci/prow/e2e-playwright 7e9ae24 link false /test e2e-playwright

Full PR test history. Your PR dashboard.

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. I understand the commands that are listed here.

@jhadvig

jhadvig commented Aug 25, 2026

Copy link
Copy Markdown
Member

/test e2e-playwright

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

Labels

component/topology Related to topology jira/severity-moderate Referenced Jira bug's severity is moderate for the branch this PR is targeting. jira/valid-bug Indicates that a referenced Jira bug is valid for the branch this PR is targeting. jira/valid-reference Indicates that this PR references a valid Jira ticket of any type. lgtm Indicates that a PR is ready to be merged. ok-to-test Indicates a non-member PR verified by an org member that is safe to test.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants