feat: enforce unique task name and other validation improvements#277
Open
JBBianchi wants to merge 4 commits into
Open
feat: enforce unique task name and other validation improvements#277JBBianchi wants to merge 4 commits into
JBBianchi wants to merge 4 commits into
Conversation
Signed-off-by: Jean-Baptiste Bianchi <jb.bianchi@neuroglia.io>
Signed-off-by: Jean-Baptiste Bianchi <jb.bianchi@neuroglia.io>
Signed-off-by: Jean-Baptiste Bianchi <jb.bianchi@neuroglia.io>
…on path Signed-off-by: Jean-Baptiste Bianchi <jb.bianchi@neuroglia.io>
Member
Author
|
@lornakelly @fantonangeli @handreyrc those changes impact the editor. |
6 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Many thanks for submitting your Pull Request ❤️!
What this PR does / why we need it:
TLDR:
New TaskListHooks.postValidation hook that rejects a TaskList containing duplicated task names, reporting every offending name.
New WorkflowValidationError base class carrying a path (RFC 6901 JSON Pointer to the offending node) and typeName. (Two subtypes: SchemaValidationError (AJV structural failures, retains raw schemaErrors) and DslValidationError (semantic/hook failures). )
validatenow runs schema validation once at the root, then walks the whole subtree invoking each nested type's lifecycle hooks. So rules like duplicate-name detection fire on nested do blocks, not just the top level. Previously hooks only ran on the validated root.New codegen (getChildTypes) emits a childTypes map describing each type's hydratable children (object / record / indexed / array / array-record). This drives the recursive walk and stays in lockstep with the constructor-hydration codegen. Notably it recurses into union-shared properties (e.g. do on both DoTask and ForTask) that the generic constructor doesn't hydrate.
Covering duplicate detection, nested tasks, and the error types/paths.
Copilot summary:
This pull request implements a robust, recursive validation framework for the Serverless Workflow SDK, introducing structured error types, lifecycle hooks for nested validation, and comprehensive test coverage. The main improvements include new error classes to distinguish schema and DSL validation failures, recursive invocation of validation hooks (including for nested structures like
TaskList), and enhanced error reporting with precise JSON Pointer paths. These changes significantly improve the reliability and debuggability of workflow validation.Validation Framework Enhancements:
src/lib/errors.ts(WorkflowValidationError,SchemaValidationError,DslValidationError) to provide structured, informative error handling for both schema and DSL validation failures. These errors include precise JSON Pointer paths and type names for better debugging.src/lib/validation.tsto:DslValidationErrorwith location context, and propagateWorkflowValidationErroras-is.Lifecycle Hooks and TaskList Validation:
TaskListHooksinsrc/lib/hooks/task-list-hooks.tsto detect and throw errors on duplicate task names within aTaskList, and registered these hooks for recursive validation. [1] [2] [3] [4]Testing Improvements:
tests/validation/task-list-validation.spec.tsand extendedtests/validation/workflow-validation.spec.tsto verify:Code Generation Support:
getChildTypesfrom reflection utilities.These changes collectively provide a more maintainable, extensible, and debuggable validation system for workflows, with clear error reporting and robust support for complex, nested workflow structures.
Special notes for reviewers:
Additional information (if needed):