Skip to content

feat: implement workflow validation to reject duplicate edges and remove redundant edge filtering logic#808

Merged
hanorik merged 2 commits into
google:wolo/workflowsfrom
hanorik:edges_validator
May 15, 2026
Merged

feat: implement workflow validation to reject duplicate edges and remove redundant edge filtering logic#808
hanorik merged 2 commits into
google:wolo/workflowsfrom
hanorik:edges_validator

Conversation

@hanorik
Copy link
Copy Markdown
Contributor

@hanorik hanorik commented May 8, 2026

This PR introduces validation to ensure that a workflow graph does not contain duplicate edges (multiple edges from the same source to the exact same destination). Enforcing this constraint at workflow creation time allows us to simplify the traversal logic during execution.

Key Changes:

  • validation.go:
    • Added validateUniqueEdges to check for duplicate edges.
    • Added validateWorkflow as a centralized entry point for workflow validation.
    • Introduced ErrDuplicateEdge.
  • workflow.go:
    • Updated New to run the validation checks and fail if they do not pass.
    • Removed the added map from findNextNodes which was previously used to filter out duplicate target nodes during traversal.
  • validation_test.go: Added unit tests to verify that duplicate edges are correctly detected.
  • workflow_test.go: Removed a test case in TestWorkflowRouting that relied on duplicate edges, as this configuration is now invalid.

@hanorik hanorik requested review from anFatum and wolo-lab May 8, 2026 10:44
@hanorik hanorik force-pushed the edges_validator branch from 38374ee to 189a9eb Compare May 8, 2026 11:32
Comment thread workflow/validation.go
Comment thread workflow/workflow.go Outdated
Comment thread workflow/workflow.go Outdated
Comment thread workflow/validation_test.go
@hanorik hanorik force-pushed the edges_validator branch from 189a9eb to b34e9c3 Compare May 11, 2026 10:12
@hanorik hanorik requested a review from wolo-lab May 11, 2026 10:19
@hanorik hanorik force-pushed the edges_validator branch from b34e9c3 to 4a70512 Compare May 11, 2026 17:41
Comment thread workflow/validation.go Outdated
Comment thread workflow/validation.go Outdated
Comment thread workflow/validation.go Outdated
@hanorik hanorik force-pushed the edges_validator branch 2 times, most recently from cc789d2 to e8692ae Compare May 15, 2026 14:23
@hanorik hanorik force-pushed the edges_validator branch from e8692ae to 97d280f Compare May 15, 2026 14:24
@hanorik hanorik merged commit 4e19087 into google:wolo/workflows May 15, 2026
1 check passed
wolo-lab pushed a commit that referenced this pull request May 18, 2026
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.

3 participants