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