feat: implement default route validation to prevent multiple default routes per node#814
Open
hanorik wants to merge 2 commits into
Open
feat: implement default route validation to prevent multiple default routes per node#814hanorik wants to merge 2 commits into
hanorik wants to merge 2 commits into
Conversation
…ove redundant edge filtering logic
wolo-lab
requested changes
May 12, 2026
| } | ||
|
|
||
| // validateWorkflow executes a set of workflow validation checks. | ||
| func validateWorkflow(workflow *Workflow) error { |
There was a problem hiding this comment.
it's not used anywhere. Please build chains from your PRs so it will be easier to merge them.
We could have something like
validateNodes(edges []Edge) error {
if err := validateSthn(...); err != nul {return err ]
\+ adding more checks like the new one here
}| for node, edges := range workflow.edges { | ||
| hasDefault := false | ||
| for _, edge := range edges { | ||
| if edge.Route == Default && !hasDefault { |
There was a problem hiding this comment.
nit (optional): consider if this is more readable
if edge.Route != Default {
continue
}
if hasDefault {
return fmt.Errof(...)
}
hasDefault = true| if err := validateDefaultRoute(&Workflow{edges: map[Node][]Edge{nodeA: tc.edges}}); err != nil && !tc.expectErr { | ||
| t.Errorf("got an error %v, expected none", err) | ||
| } else if err == nil && tc.expectErr { | ||
| t.Errorf("expected an error, got none") |
There was a problem hiding this comment.
maybe let's check if we got the proper error type (errors.IS)?
450cc4e to
390b879
Compare
390b879 to
d3897d4
Compare
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.
This PR introduces validation to ensure that a node in a workflow graph does not have more than one default route.
Key Changes:
validateDefaultRouteinvalidation.goto ensure each node has at most one outgoing edge withDefaultroute. It returns a new errorErrMultipleDefaultRoutesif a violation is found.TestDefaultRouteinvalidation_test.goto verify the behavior with both valid and invalid configurations.