Bug 1913969

Summary: Field dependency descriptor can sometimes cause an exception
Product: OpenShift Container Platform Reporter: Jon Jackson <jonjacks>
Component: Management ConsoleAssignee: Jon Jackson <jonjacks>
Status: CLOSED ERRATA QA Contact: Yadan Pei <yapei>
Severity: medium Docs Contact:
Priority: unspecified    
Version: 4.5CC: aos-bugs, jokerman, yapei
Target Milestone: ---Keywords: UpcomingSprint
Target Release: 4.7.0   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Cause: `getJSONSchemaPropertySortWeight` helper function would recurse infinitely if a fieldDependency descriptor was applied to a schema property using a control field with an identical name. Consequence: The DynamicForm component would throw an exception under the above condition. Fix: In `getJSONSchemaPropertySortWeight` helper function, keep track of the current path and use the entire path to determine dependency relationship instead of just the field names. Result: DynamicForm no longer throws an exception under the above condition.
Story Points: ---
Clone Of: Environment:
Last Closed: 2021-02-24 15:51:24 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:

Description Jon Jackson 2021-01-07 21:34:24 UTC
From https://github.com/openshift/console/issues/6182:

With OCP 4.5+, the console UI crashes due to what seems to be the path property name contains the same property name of the fieldDependency. In the following example, enabled is in both the path topology.appDisco.enabled and the x-descriptor urn:alm:descriptor:com.tectonic.ui:fieldDependency:topology.enabled:true:

      - description: Enable Application Discovery  and Application Discovery  Observer
        displayName: Application Discovery
        path: topology.appDisco.enabled
        x-descriptors:
        - urn:alm:descriptor:com.tectonic.ui:booleanSwitch
        - urn:alm:descriptor:com.tectonic.ui:fieldDependency:topology.enabled:true
        - urn:alm:descriptor:com.tectonic.ui:fieldGroup:topology

When trying to create the custom resource via the OCP UI via the Form view, the browser crashes:

vendors~main-chunk-7a7a26f2297ed1999af3.min.js:161388 RangeError: Maximum call stack size exceeded
    at Object.t.a (vendors~main-chunk-7a7a26f2297ed1999af3.min.js:18508)
    at s (create-operand-chunk-b84d6e080d8c4e9c11ea.min.js:1)
    at s (create-operand-chunk-b84d6e080d8c4e9c11ea.min.js:1)
    at s (create-operand-chunk-b84d6e080d8c4e9c11ea.min.js:1)
    at s (create-operand-chunk-b84d6e080d8c4e9c11ea.min.js:1)
    at s (create-operand-chunk-b84d6e080d8c4e9c11ea.min.js:1)
    at s (create-operand-chunk-b84d6e080d8c4e9c11ea.min.js:1)
    at s (create-operand-chunk-b84d6e080d8c4e9c11ea.min.js:1)
    at s (create-operand-chunk-b84d6e080d8c4e9c11ea.min.js:1)
    at s (create-operand-chunk-b84d6e080d8c4e9c11ea.min.js:1)

If I change the property name of the path or fieldDependency to be unique from each other (i.e. enabledx), the UI works. We also didn't see this problem in OCP 4.4, but only within OCP 4.5+.

Comment 3 Yadan Pei 2021-02-03 06:03:14 UTC
Hi Jon,

Could you tell me which operator can easily reproduce the issue?

Comment 4 Jon Jackson 2021-02-03 19:05:03 UTC
Hi Yadan, 

I don't know of an existing operator, but I've created a gist with the YAML to create a mock Operator similar to what I used to reproduce. I added a link in the bug details.

Just create the CRD, then create the CSV in whatever namespace you want and you should see a "Mock Operator" on the Installed Operators page. It provides one CR: "MockResource" and attempting to create an instance of that resource should reproduce the bug before my fix.

Comment 5 Jon Jackson 2021-02-03 19:06:18 UTC
Here's the gist:

https://gist.github.com/TheRealJon/3680c8a573bde88a974588e269230562

Comment 6 Yadan Pei 2021-02-04 03:07:16 UTC
Thank you very much Jon,

The mock csv and crd yaml is very helpful, I created them and tried to create an instance of 'MockResource', the browser didn't crash

Verified on 4.7.0-0.nightly-2021-02-03-165316

Comment 9 errata-xmlrpc 2021-02-24 15:51:24 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.7.0 security, bug fix, and enhancement 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-2020:5633