Bug 1933857

Summary: Details page can throw an uncaught exception if kindObj prop is undefined
Product: OpenShift Container Platform Reporter: Jon Jackson <jonjacks>
Component: Management ConsoleAssignee: Jon Jackson <jonjacks>
Status: CLOSED ERRATA QA Contact: Yadan Pei <yapei>
Severity: low Docs Contact:
Priority: unspecified    
Version: 4.8CC: aos-bugs, jokerman, spadgett, yapei
Target Milestone: ---   
Target Release: 4.8.0   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard: Scrubbed
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.
Story Points: ---
Clone Of: Environment:
Last Closed: 2021-07-27 22:48:44 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Attachments:
Description Flags
always loading page none

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