Bug 1933857 - Details page can throw an uncaught exception if kindObj prop is undefined
Summary: Details page can throw an uncaught exception if kindObj prop is undefined
Keywords:
Status: CLOSED ERRATA
Alias: None
Product: OpenShift Container Platform
Classification: Red Hat
Component: Management Console
Version: 4.8
Hardware: Unspecified
OS: Unspecified
unspecified
low
Target Milestone: ---
: 4.8.0
Assignee: Jon Jackson
QA Contact: Yadan Pei
URL:
Whiteboard: Scrubbed
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2021-03-01 21:11 UTC by Jon Jackson
Modified: 2021-07-27 22:49 UTC (History)
4 users (show)

Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Cause: A breadcrumb helper useBreadCrumbForDetailPage hook was using `kindObj` property without a null check. Consequence: If kindObj was null, an uncaught exception was thrown. Fix: Add optional chaining to kindObj references in useBreadCrumbForDetailPage hook Result: The hook no longer throws an exception when kindObj is undefined. Additionally, logic was added so that if a user is visiting a details page for a resource without a model, they will get a 404 error.
Clone Of:
Environment:
Last Closed: 2021-07-27 22:48:44 UTC
Target Upstream Version:
Embargoed:


Attachments (Terms of Use)
always loading page (203.47 KB, image/png)
2021-03-09 03:00 UTC, Yadan Pei
no flags Details


Links
System ID Private Priority Status Summary Last Updated
Github openshift console pull 8271 0 None open Bug 1933857: Fix uncaught exception in DetailsPage component 2021-03-01 21:32:40 UTC
Github openshift console pull 8443 0 None open Bug 1933857: Follow on fix to ensure operand details page 404s when no model is found 2021-03-22 20:06:24 UTC
Red Hat Product Errata RHSA-2021:2438 0 None None None 2021-07-27 22:49:03 UTC

Description Jon Jackson 2021-03-01 21:11:03 UTC
Description of problem:
Local hook 'useBreadCrumbForDetailPage' throws an uncaught exception when `kindObj` parameter is undefined, which is possible in some edge cases. For instance, visiting an operand details page route for a non-existent CRD.

Version-Release number of selected component (if applicable):
4.8

How reproducible:
Always

Steps to Reproduce:
1. Install any operator in a specific namespace of your choice
2. Vist the operator details page and note the name of the CSV for the next step
3. Navigate to '/k8s/ns/{namespaceFrom StepOne}/clusterserviceversions/{csvNameFromStepTwo}/{aRandomString}/{anotherRandomString}'

Actual results:
An uncaught exception is thrown:

Uncaught TypeError: Cannot read property 'kind' of undefined
    at useBreadCrumbsForDetailPage (details.tsx:54)
    at details.tsx:85
    at renderWithHooks (react-dom.development.js:15108)
    at mountIndeterminateComponent (react-dom.development.js:17342)
    at beginWork$1 (react-dom.development.js:18486)
    at HTMLUnknownElement.callCallback (react-dom.development.js:347)
    at Object.invokeGuardedCallbackDev (react-dom.development.js:397)
    at invokeGuardedCallback (react-dom.development.js:454)
    at beginWork$$1 (react-dom.development.js:23217)
    at performUnitOfWork (react-dom.development.js:22208)


Expected results:
A 404 error page should be shown

Comment 2 Yadan Pei 2021-03-08 07:23:54 UTC
fix is not merged in 4.8.0-0.nightly-2021-03-06-055252, will check on new build

Comment 3 Yadan Pei 2021-03-09 03:00:41 UTC
Created attachment 1761882 [details]
always loading page

1. Install any operator in a specific namespace of your choice
2. Vist the operator details page and note the name of the CSV for the next step
3. Navigate to '/k8s/ns/yapei/clusterserviceversions/etcdoperator.v0.9.4/randomstring/anotherRandomString', in browser console it shows `No model registered for randomstring` but in web console we always show a loading page rather tha 404 

Moving back for double confirmation and further investigation

Comment 5 Yadan Pei 2021-04-06 08:10:54 UTC
verified with steps in comment 3, now it renders an error page with message `404: Page Not Found` 

Verified on     4.8.0-0.nightly-2021-04-05-174735

Comment 8 errata-xmlrpc 2021-07-27 22:48:44 UTC
Since the problem described in this bug report should be
resolved in a recent advisory, it has been closed with a
resolution of ERRATA.

For information on the advisory (Moderate: OpenShift Container Platform 4.8.2 bug fix and security update), and where to find the updated
files, follow the link below.

If the solution does not work for you, open a new bug report.

https://access.redhat.com/errata/RHSA-2021:2438


Note You need to log in before you can comment on or make changes to this bug.