Bug 1913969 - Field dependency descriptor can sometimes cause an exception
Summary: Field dependency descriptor can sometimes cause an exception
Keywords:
Status: CLOSED ERRATA
Alias: None
Product: OpenShift Container Platform
Classification: Red Hat
Component: Management Console
Version: 4.5
Hardware: Unspecified
OS: Unspecified
unspecified
medium
Target Milestone: ---
: 4.7.0
Assignee: Jon Jackson
QA Contact: Yadan Pei
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2021-01-07 21:34 UTC by Jon Jackson
Modified: 2021-02-24 15:51 UTC (History)
3 users (show)

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.
Clone Of:
Environment:
Last Closed: 2021-02-24 15:51:24 UTC
Target Upstream Version:


Attachments (Terms of Use)


Links
System ID Private Priority Status Summary Last Updated
Github openshift console pull 7957 0 None closed Bug 1890180: Bug 1913969: Fix edge case exception for fieldDependency spec descriptor and add support for non-sibling co... 2021-02-18 16:04:55 UTC
Red Hat Product Errata RHSA-2020:5633 0 None None None 2021-02-24 15:51:39 UTC

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


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