diff --git a/internal/terraform/graph.go b/internal/terraform/graph.go index 9e2f195531..cc99942093 100644 --- a/internal/terraform/graph.go +++ b/internal/terraform/graph.go @@ -82,8 +82,9 @@ func (g *Graph) walk(walker GraphWalker) tfdiags.Diagnostics { log.Printf("[TRACE] vertex %q: expanding dynamic subgraph", dag.VertexName(v)) g, err := ev.DynamicExpand(vertexCtx) - if err != nil { - diags = diags.Append(err) + diags = diags.Append(err) + if diags.HasErrors() { + log.Printf("[TRACE] vertex %q: failed expanding dynamic subgraph: %s", dag.VertexName(v), err) return } if g != nil { diff --git a/internal/terraform/transform_expand.go b/internal/terraform/transform_expand.go index dca71b630f..6d9b92aeee 100644 --- a/internal/terraform/transform_expand.go +++ b/internal/terraform/transform_expand.go @@ -5,5 +5,13 @@ package terraform // These nodes are given the eval context and are expected to return // a new subgraph. type GraphNodeDynamicExpandable interface { + // DynamicExpand returns a new graph which will be treated as the dynamic + // subgraph of the receiving node. + // + // The second return value is of type error for historical reasons; + // it's valid (and most ideal) for DynamicExpand to return the result + // of calling ErrWithWarnings on a tfdiags.Diagnostics value instead, + // in which case the caller will unwrap it and gather the individual + // diagnostics. DynamicExpand(EvalContext) (*Graph, error) }