appsmithorg / appsmith

Platform to build admin panels, internal tools, and dashboards. Integrates with 25+ databases and any API.
https://www.appsmith.com
Apache License 2.0
34.63k stars 3.74k forks source link

[Bug]: Evaluations returns the exepected value later in the cycles #23825

Open keyurparalkar opened 1 year ago

keyurparalkar commented 1 year ago

Is there an existing issue for this?

Description

It is observed that for the JSONForm widget whenever we have a field that recieves the data as Array of objects or nested object structure then the defaultValue is getting evaluated late in the cycles.

Consider the following scenario: For the Array field type, the defaultValue property is not getting evaluated correctly. Since it is an array field we expect that the value should directly get evaluated to an array but instead it gets first evaluated to string and in the later cycles it resolves to array.

Here is the observations while debugging: 1st Cycle: Validation config: STRING

evalTree output: schema._root_schema_.genres.defaultValue = '[{"name":"Action","id":28},{"name":"Adventure","id":12},{"name":"Science Fiction","id":878}]'

2nd Cycle: Validation config: ARRAY

evalTree output: same as above string value

3rd Cycle: Validation config: ARRAY

evalTree output: = Gives the correct array i.e. [ { "name": "Action", "id": 28 }, { "name": "Adventure", "id": 12 }, { "name": "Science Fiction", "id": 878 } ]

As you can see from above even if the validation config has changed to ARRAY type in 2nd eval but still in the eval tree we get string value.

Here the expected behaviour should be that the defaultValue should get evaluated in the second cycle itself.

Steps To Reproduce

Public Sample App

No response

Environment

Production

Issue video log

No response

Version

Cloud

bharath31 commented 1 year ago

@arunvjn could you investigate the reason for delayed evaluations?