Skip to content

Commit 0573724

Browse files
Merge pull request #25 from actionforge/bugfix/group-error-validation
Fix ghost error in validation function when group node has issues
2 parents f240a68 + 462ab01 commit 0573724

2 files changed

Lines changed: 14 additions & 5 deletions

File tree

core/base.go

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -618,8 +618,14 @@ func NewNodeInstance(nodeType string, parent NodeBaseInterface, parentId string,
618618
// Pass 'validate' to the factory function
619619
node, errs = factoryEntry.FactoryFn(nil, parent, parentId, nodeDef, validate, opts)
620620
if len(errs) > 0 {
621-
// If the factory failed to produce a node (or found errors), return them.
622-
return nil, errs
621+
if node == nil || !validate {
622+
// factory failed to produce a node, or we're not in validation mode.
623+
return nil, errs
624+
}
625+
// factory produced a valid node but found validation errors (eg group
626+
// with sub-graph errors). We continue here so the parent graph
627+
// at least can continue to register the node and report. All the
628+
// validation errors are returned anyway, so nothing is lost.
623629
}
624630
} else {
625631
return nil, []error{CreateErr(nil, nil, "unknown node type '%v'", nodeType)}
@@ -658,7 +664,7 @@ func NewNodeInstance(nodeType string, parent NodeBaseInterface, parentId string,
658664
node.SetNodeType(nodeType)
659665
node.SetName(factoryEntry.Name)
660666
node.SetParent(parent)
661-
return node, nil
667+
return node, errs
662668
}
663669

664670
func GlobFilter(path string, pattern []string) (bool, error) {

nodes/group@v1.go

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -291,8 +291,11 @@ func init() {
291291
}
292292
}
293293

294-
if len(collectedErrors) > 0 {
295-
return nil, collectedErrors
294+
if len(collectedErrors) > 0 && !validate {
295+
// Return the collected errors instead of nil to prevent cascading
296+
// validation errors where the group node is never registered in the
297+
// parent graph, causing some ghost errors about missing nodes
298+
return group, collectedErrors
296299
}
297300

298301
return group, nil

0 commit comments

Comments
 (0)