Bug 1937018 - FilterToolbar component does not handle 'null' value for 'rowFilters' prop
Summary: FilterToolbar component does not handle 'null' value for 'rowFilters' prop
Keywords:
Status: CLOSED ERRATA
Alias: None
Product: OpenShift Container Platform
Classification: Red Hat
Component: Management Console
Version: 4.6
Hardware: Unspecified
OS: Unspecified
unspecified
medium
Target Milestone: ---
: 4.8.0
Assignee: Jon Jackson
QA Contact: Yadan Pei
URL:
Whiteboard:
Depends On:
Blocks: 1939608
TreeView+ depends on / blocked
 
Reported: 2021-03-09 17:00 UTC by Jon Jackson
Modified: 2021-07-27 22:52 UTC (History)
4 users (show)

Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Cause: rowFilters prop in FilterToolbar component was not null-checked. Consequence: Uncaught exception was thrown if rowFilters prop was undefined. Fix: Add null coalescence or optional chaining wherever rowFilters prop is referenced in FilterToolbar component. Result: FilterToolbar does not throw uncaught exception when rowFilters prop is undefined.
Clone Of:
: 1939608 (view as bug list)
Environment:
Last Closed: 2021-07-27 22:52:25 UTC
Target Upstream Version:
Embargoed:


Attachments (Terms of Use)
Screen shot (259.94 KB, image/png)
2021-03-09 17:00 UTC, Jon Jackson
no flags Details


Links
System ID Private Priority Status Summary Last Updated
Github openshift console pull 8391 0 None open Bug 1937018: Fix null handling in FilterToolbar_ to prevent possible exceptions 2021-03-16 17:06:34 UTC
Red Hat Product Errata RHSA-2021:2438 0 None None None 2021-07-27 22:52:54 UTC

Description Jon Jackson 2021-03-09 17:00:42 UTC
Created attachment 1762036 [details]
Screen shot

Created attachment 1762036 [details]
Screen shot

Created attachment 1762036 [details]
Screen shot

Description of problem:
The FilterToolbar component references 'props.rowFilters.reduce' without using optional chaining or a null check. This can break if 'null' is passed into that prop.

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

How reproducible:
Always

Steps to Reproduce:
1. Create crd, csv, and cr-instance from this gist: https://gist.github.com/TheRealJon/3680c8a573bde88a974588e269230562
2. Visit Operators > Installed Operators > Mock Operator
3. On the details page, click the All Instances tab

Actual results:
An uncaught exception is thrown and the page shows "Oh no! Something went wrong."

Expected results:
A list page with the one operand instance should be shown.

Additional info:
ProvidedAPIsPage component passes 'null' to rowFilters prop of MultiListPage component if there is one or less provided APIs.  This breaks in FilterToolbar component, which doesn't use optional chaining or any null check on the rowFilters prop before referencing rowFilters. This isn't reproduced in 4.7+ because we improved the filtering of provided APIS, and the All Instances tab is not rendered when only one API is provided.

Browser console output:

Uncaught error TypeError: Cannot read property 'reduce' of null
    at FilterToolbar_ (main-c2916049073ccd2dbd6d.js:90028)
    at renderWithHooks (vendors~main-96a1f70a31716de9da69.js:373407)
    at mountIndeterminateComponent (vendors~main-96a1f70a31716de9da69.js:375641)
    at beginWork$1 (vendors~main-96a1f70a31716de9da69.js:376785)
    at HTMLUnknownElement.callCallback (vendors~main-96a1f70a31716de9da69.js:358646)
    at Object.invokeGuardedCallbackDev (vendors~main-96a1f70a31716de9da69.js:358696)
    at invokeGuardedCallback (vendors~main-96a1f70a31716de9da69.js:358753)
    at beginWork$$1 (vendors~main-96a1f70a31716de9da69.js:381516)
    at performUnitOfWork (vendors~main-96a1f70a31716de9da69.js:380507)
    at workLoopSync (vendors~main-96a1f70a31716de9da69.js:380484)

The above error occurred in the <FilterToolbar_> component:
    in FilterToolbar_ (created by ConnectFunction)
    in ConnectFunction (created by Context.Consumer)
    in FilterToolbar (created by ListPageWrapper_)
    in div (created by ListPageWrapper_)
    in ListPageWrapper_ (created by MultiListPage)
    in Unknown
    in Unknown (created by ConnectFunction)
    in ConnectFunction (created by Firehose)
    in Firehose (created by ConnectFunction)
    in ConnectFunction (created by MultiListPage)
    in div (created by ConnectedFireMan)
    in ConnectedFireMan (created by ConnectFunction)
    in ConnectFunction
    in ConnectFunction (created by MultiListPage)
    in MultiListPage
    in Unknown (created by ConnectFunction)
    in ConnectFunction (created by Context.Consumer)
    in Route
    in Switch
    in div (created by Data)
    in Data (created by StatusBox)
    in StatusBox
    in div
    in Unknown
    in Unknown
    in Unknown
    in Unknown (created by ConnectFunction)
    in ConnectFunction (created by Firehose)
    in Firehose (created by ConnectFunction)
    in ConnectFunction
    in Unknown (created by DetailsPage)
    in ErrorBoundary (created by DetailsPage)
    in DetailsPage (created by ClusterServiceVersionsDetailsPage)
    in ClusterServiceVersionsDetailsPage (created by AsyncComponent)
    in AsyncComponent
    in Unknown (created by ConnectFunction)
    in ConnectFunction (created by Context.Consumer)
    in Route (created by AppContents_)
    in Switch (created by AppContents_)
    in div (created by AppContents_)
    in div (created by AppContents_)
    in section (created by PageSection)
    in PageSection (created by AppContents_)
    in AppContents_ (created by ConnectFunction)
    in ConnectFunction (created by App_)
    in div (created by DrawerContent)
    in div (created by DrawerMain)
    in DrawerMain (created by DrawerContent)
    in DrawerContent (created by NotificationDrawer)
    in div (created by Drawer)
    in Drawer (created by NotificationDrawer)
    in NotificationDrawer (created by ConnectedNotificationDrawer_)
    in ConnectedNotificationDrawer_ (created by ConnectFunction)
    in ConnectFunction (created by App_)
    in main (created by Page)
    in div (created by Page)
    in Page (created by App_)
    in div (created by DrawerContentBody)
    in DrawerContentBody (created by QuickStartDrawer)
    in div (created by DrawerContent)
    in div (created by DrawerMain)
    in DrawerMain (created by DrawerContent)
    in DrawerContent (created by QuickStartDrawer)
    in div (created by Drawer)
    in Drawer (created by QuickStartDrawer)
    in QuickStartDrawer (created by ConnectFunction)
    in ConnectFunction (created by App_)
    in EnhancedProvider (created by App_)
    in DetectPerspective (created by ConnectFunction)
    in ConnectFunction (created by App_)
    in App_ (created by ConnectFunction)
    in ConnectFunction (created by Context.Consumer)
    in Route
    in Switch
    in Router
    in Provider

Comment 4 Yanping Zhang 2021-03-18 03:47:33 UTC
Since the All Instances tab is not rendered when only one API is provided on ocp 4.8, so the bug doesn't exist on ocp 4.8 cluster, and also checked on ocp 4.8 cluster with payload 4.8.0-0.nightly-2021-03-17-160945 which contains the update from the pr, there is no other issue found.

Comment 7 errata-xmlrpc 2021-07-27 22:52:25 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.