fix(ui): handle parsing errors properly in object editor #13931
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Motivation
#13915 introduced a regression where edits made in an object editor that introduce syntax errors cause a full screen error.
This is happening because parsing was lifted out of
<ObjectEditor>
and into a reducer. Before #13915, the object editor used the following to catch parse errors:argo-workflows/ui/src/shared/components/object-editor.tsx
Lines 131 to 136 in eb4f245
After #13915, the parsing logic was moved to
reducer()
, which is executed async, and therefore errors aren't propagated to thecatch (e) {}
block:argo-workflows/ui/src/shared/components/object-editor.tsx
Lines 117 to 122 in 1392ef5
Modifications
This moves the parsing logic to the
setObject()
function (which gets passed asonChange
to<ObjectEditor>
), which means errors will now be caught by thecatch (e) {}
block.Verification
Tested by going http://localhost:8080/workflow-templates, creating a new
WorkflowTemplate
, and making edits.fix_error_handling.mp4