Fix Trigger UI form rendering for null enum values#62060
Fix Trigger UI form rendering for null enum values#62060bbovenzi merged 4 commits intoapache:mainfrom
Conversation
8157c2b to
88a1b18
Compare
jscheffl
left a comment
There was a problem hiding this comment.
Static checks are failing most probably you should install prekand run static checks locally. What I see as compliaints can all be auo-fixed.
88a1b18 to
39b82c7
Compare
39b82c7 to
b8d6de2
Compare
When a numeric enum value (e.g. 6) was selected, the Select component
returned a string ('6'). The old code stored the string directly, causing
a 400 Bad Request since backend validation expects the integer 6.
Fix: look up the original typed value from schema.enum using the string
as a key, and store that instead of the raw string from the UI.
Regression test added to FieldDropdown.test.tsx.
|
@jscheffl The root cause of this issue was that the Select component always returns string values, so numeric enum values (e.g. 6) were being submitted as the string "6" instead of the number 6, causing a validation error on submit. |
- Broaden ParamSchema.enum type to Array<boolean | number | string | null> to accurately reflect JSON Schema enum values (fixes no-unnecessary-condition) - Update labelLookup signature to accept boolean - Switch null-check ternaries to nullish coalescing (??) in FieldDropdown.tsx - Add eslint-disable for no-unsafe-member-access on any-typed mockParamsDict access - Remove stale/unused eslint-disable-next-line comments
pierrejeambrun
left a comment
There was a problem hiding this comment.
Static checks are not happy.
Also I recommend installing the pre-commit (prek) hooks so you can have early feedback (at commit time) instead of waiting for the CI to realize that you have a formatting or linting error.
contributing-docs/08_static_code_checks.rst
jscheffl
left a comment
There was a problem hiding this comment.
For me looks very good now. Thanks for the (multiple) rework! LGTM so that it is fixed in next release!
@pierrejeambrun as not being UI codeowner, can you (or some other) make a final 2nd pass review prior merge?
* Fix Trigger UI form rendering for null enum values
* fix: preserve original type when selecting numeric enum in FieldDropdown
When a numeric enum value (e.g. 6) was selected, the Select component
returned a string ('6'). The old code stored the string directly, causing
a 400 Bad Request since backend validation expects the integer 6.
Fix: look up the original typed value from schema.enum using the string
as a key, and store that instead of the raw string from the UI.
Regression test added to FieldDropdown.test.tsx.
* fix: resolve ts-compile-lint-ui ESLint errors in FieldDropdown
- Broaden ParamSchema.enum type to Array<boolean | number | string | null>
to accurately reflect JSON Schema enum values (fixes no-unnecessary-condition)
- Update labelLookup signature to accept boolean
- Switch null-check ternaries to nullish coalescing (??) in FieldDropdown.tsx
- Add eslint-disable for no-unsafe-member-access on any-typed mockParamsDict access
- Remove stale/unused eslint-disable-next-line comments
* fix: handle null enum values in FieldMultiSelect TypeScript types
(cherry picked from commit 4d3230c)
* Fix Trigger UI form rendering for null enum values
* fix: preserve original type when selecting numeric enum in FieldDropdown
When a numeric enum value (e.g. 6) was selected, the Select component
returned a string ('6'). The old code stored the string directly, causing
a 400 Bad Request since backend validation expects the integer 6.
Fix: look up the original typed value from schema.enum using the string
as a key, and store that instead of the raw string from the UI.
Regression test added to FieldDropdown.test.tsx.
* fix: resolve ts-compile-lint-ui ESLint errors in FieldDropdown
- Broaden ParamSchema.enum type to Array<boolean | number | string | null>
to accurately reflect JSON Schema enum values (fixes no-unnecessary-condition)
- Update labelLookup signature to accept boolean
- Switch null-check ternaries to nullish coalescing (??) in FieldDropdown.tsx
- Add eslint-disable for no-unsafe-member-access on any-typed mockParamsDict access
- Remove stale/unused eslint-disable-next-line comments
* fix: handle null enum values in FieldMultiSelect TypeScript types
(cherry picked from commit 4d3230c)
Co-authored-by: Subham <subhamsangwan26@gmail.com>
* Fix Trigger UI form rendering for null enum values
* fix: preserve original type when selecting numeric enum in FieldDropdown
When a numeric enum value (e.g. 6) was selected, the Select component
returned a string ('6'). The old code stored the string directly, causing
a 400 Bad Request since backend validation expects the integer 6.
Fix: look up the original typed value from schema.enum using the string
as a key, and store that instead of the raw string from the UI.
Regression test added to FieldDropdown.test.tsx.
* fix: resolve ts-compile-lint-ui ESLint errors in FieldDropdown
- Broaden ParamSchema.enum type to Array<boolean | number | string | null>
to accurately reflect JSON Schema enum values (fixes no-unnecessary-condition)
- Update labelLookup signature to accept boolean
- Switch null-check ternaries to nullish coalescing (??) in FieldDropdown.tsx
- Add eslint-disable for no-unsafe-member-access on any-typed mockParamsDict access
- Remove stale/unused eslint-disable-next-line comments
* fix: handle null enum values in FieldMultiSelect TypeScript types
(cherry picked from commit 4d3230c)
Co-authored-by: Subham <subhamsangwan26@gmail.com>
* Fix Trigger UI form rendering for null enum values
* fix: preserve original type when selecting numeric enum in FieldDropdown
When a numeric enum value (e.g. 6) was selected, the Select component
returned a string ('6'). The old code stored the string directly, causing
a 400 Bad Request since backend validation expects the integer 6.
Fix: look up the original typed value from schema.enum using the string
as a key, and store that instead of the raw string from the UI.
Regression test added to FieldDropdown.test.tsx.
* fix: resolve ts-compile-lint-ui ESLint errors in FieldDropdown
- Broaden ParamSchema.enum type to Array<boolean | number | string | null>
to accurately reflect JSON Schema enum values (fixes no-unnecessary-condition)
- Update labelLookup signature to accept boolean
- Switch null-check ternaries to nullish coalescing (??) in FieldDropdown.tsx
- Add eslint-disable for no-unsafe-member-access on any-typed mockParamsDict access
- Remove stale/unused eslint-disable-next-line comments
* fix: handle null enum values in FieldMultiSelect TypeScript types

This PR fixes a regression where the Trigger UI form crashes if a parameter's enum contains
null(used to make fields optional).The
zag-jslibrary (used by Chakra UI's Select component) requires string values for dropdown items. Whennullis passed in an enum, it causes a crash with[zag-js] No value found for item {"label":null,"value":null}.This fix:
nullenum values are converted to the string"null"specifically for the UI rendering."null"is converted back to the actualnullprimitive in the form state.nullkeys.I've added comprehensive unit tests in FieldDropdown.test.tsx covering:
nullnullviavalues_displaycloses: #62049
Was generative AI tooling used to co-author this PR?