Skip to content

Parse and store SDK validation errors in state#173

Open
handreyrc wants to merge 5 commits into
serverlessworkflow:mainfrom
handreyrc:workflow-errors
Open

Parse and store SDK validation errors in state#173
handreyrc wants to merge 5 commits into
serverlessworkflow:mainfrom
handreyrc:workflow-errors

Conversation

@handreyrc

@handreyrc handreyrc commented Jun 9, 2026

Copy link
Copy Markdown
Contributor

Closes #96

Summary

This PR introtuces means to handle and parse validation errors into an array and keep errors up-to-date it in the store.
e.g.
'Workflow' is invalid: 'Workflow' is invalid:
- /do/0/checkup | #/oneOf/0/required | must have required property 'call' | {"missingProperty":"call"}
- /do/0/checkup | #/oneOf/0/required | must have required property 'call' | {"missingProperty":"call"}

Changes

  • Added ValidationError type to handle validation errors.
  • Added SdkError type to work as a mixed array for Parse and validation errors.
  • Added a function to parse validation error messages into an arry of validation errors
  • Ajusted the error page to handle the SDKError type instead of Error type.
  • Added tests covering changes in the validation and error parsing.

handreyrc added 2 commits June 8, 2026 20:47
Signed-off-by: handreyrc <handrey.cunha@gmail.com>
Signed-off-by: handreyrc <handrey.cunha@gmail.com>
Copilot AI review requested due to automatic review settings June 9, 2026 01:11
@netlify

netlify Bot commented Jun 9, 2026

Copy link
Copy Markdown

Deploy Preview for swf-editor ready!

Name Link
🔨 Latest commit 6965c3e
🔍 Latest deploy log https://app.netlify.com/projects/swf-editor/deploys/6a288ace4355c100075e4e04
😎 Deploy Preview https://deploy-preview-173--swf-editor.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Note

Copilot was unable to run its full agentic suite in this review.

This PR enhances how SDK validation failures are represented by parsing SDK validation error messages into structured objects, updating the editor store/types accordingly, and adding tests to cover the new behavior.

Changes:

  • Introduce ValidationError / SdkError and parse SDK validation output into structured errors.
  • Update store/context and error-page rendering to handle non-Error validation entries safely.
  • Add fixtures + integration/UI tests (with snapshots) for validation error parsing and fallback messaging.

Reviewed changes

Copilot reviewed 9 out of 9 changed files in this pull request and generated 5 comments.

Show a summary per file
File Description
packages/serverless-workflow-diagram-editor/src/core/workflowSdk.ts Adds ValidationError/SdkError, parseValidationErrorMessage, and updates validation flow to return parsed errors.
packages/serverless-workflow-diagram-editor/src/store/DiagramEditorContext.tsx Updates context errors type to SdkError[].
packages/serverless-workflow-diagram-editor/src/diagram-editor/error-pages/ParsingErrorPage.tsx Guards YAML exception checks with err instanceof Error for mixed error arrays.
packages/serverless-workflow-diagram-editor/tests/core/workflowSdk.integration.test.ts Adds tests for parsing validation errors and updates invalid-workflow expectations.
packages/serverless-workflow-diagram-editor/tests/core/snapshots/workflowSdk.integration.test.ts.snap Updates snapshots for new parsed validation error output.
packages/serverless-workflow-diagram-editor/tests/diagram-editor/error-pages/ParsingErrorPage.test.tsx Adds tests ensuring ValidationError entries fall back to default error copy.
packages/serverless-workflow-diagram-editor/tests/fixtures/workflows.ts Adds YAML fixture intended to trigger validation errors.
packages/serverless-workflow-diagram-editor/tests/react-flow/diagram/Diagram.test.tsx Minor adjustment to ReactFlow mock signature.
.changeset/parse-sdk-validation-errors.md Changeset documenting the new behavior as a minor bump.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread packages/serverless-workflow-diagram-editor/src/core/workflowSdk.ts
Comment thread packages/serverless-workflow-diagram-editor/src/core/workflowSdk.ts
Comment thread packages/serverless-workflow-diagram-editor/tests/fixtures/workflows.ts Outdated
Signed-off-by: handreyrc <handrey.cunha@gmail.com>
}

// Validate all required fields are non-empty
if (!taskId || !errorType || !errorMessage || !objectStr) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like the taskId is a path but I think the path can be empty if there is an error in top level, like if document is missing? This check would mean we miss those errors?

@handreyrc handreyrc Jun 9, 2026

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@lornakelly,

Missing Document session:
In this case, it causes a parser error that is later handled by the error page, it does not get to the validation.

Missing properties in Document session:
- /document | #/properties/document/required | must have required property 'namespace' | {"missingProperty":"namespace"}
This one I checked before submitting the PR, as you can see it meets the 4 fields standard so no issues here.

Wrong DSL version:
'Workflow' is invalid - The DSL version of the workflow '1.0.0' doesn't match the supported version of the SDK '1.0.3'.
This one is problem, so I changed the ValidationError type and validation error parser to handle this sort of message too.

It should be fixed now!

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks

do: [],
});

export const VALID_WORKFLOW_WITH_VALIDATION_ERRORS_YAML = `

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was a little confused by this name :) Just a small suggestionMaybe PARSEABLE_INVALID_WORKFLOW_YAML`?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed!

expect(errors[0].object).toEqual({});
});

it("rejects array JSON and falls back to empty object", () => {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe create an it.each for tests asserting {} to reduce repetition

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed!

Signed-off-by: handreyrc <handrey.cunha@gmail.com>
Copilot AI review requested due to automatic review settings June 9, 2026 21:22

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 9 out of 9 changed files in this pull request and generated 8 comments.

Comment thread packages/serverless-workflow-diagram-editor/src/core/workflowSdk.ts
Comment thread packages/serverless-workflow-diagram-editor/src/core/workflowSdk.ts
Comment thread packages/serverless-workflow-diagram-editor/src/core/workflowSdk.ts
Comment thread packages/serverless-workflow-diagram-editor/src/core/workflowSdk.ts
Comment thread packages/serverless-workflow-diagram-editor/src/core/workflowSdk.ts
Comment thread packages/serverless-workflow-diagram-editor/src/core/workflowSdk.ts
Comment thread packages/serverless-workflow-diagram-editor/src/core/workflowSdk.ts
Signed-off-by: handreyrc <handrey.cunha@gmail.com>
@handreyrc handreyrc requested a review from lornakelly June 9, 2026 21:56

@lornakelly lornakelly left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

feat: Parse and store SDK validation errors in state

3 participants