hashicorp/terraform · error
error marshaling relevant attributes for external changes: %
Error message
error marshaling relevant attributes for external changes: %s
What it means
Top-level wrapper: output.marshalRelevantAttrs failed. That function encodes each RelevantAttributes entry's cty.Path via encodePath; a failure means a path step could not be JSON-encoded (typically surfacing errors 618 or 619).
Source
Thrown at internal/command/jsonplan/plan.go:298
// we skip them here.
var driftedResources []*plans.ResourceInstanceChangeSrc
if p.UIMode == plans.RefreshOnlyMode {
driftedResources = p.DriftedResources
} else {
for _, dr := range p.DriftedResources {
if dr.Action != plans.NoOp {
driftedResources = append(driftedResources, dr)
}
}
}
output.ResourceDrift, err = MarshalResourceChanges(driftedResources, schemas)
if err != nil {
return nil, fmt.Errorf("error in marshaling resource drift: %s", err)
}
}
if err := output.marshalRelevantAttrs(p); err != nil {
return nil, fmt.Errorf("error marshaling relevant attributes for external changes: %s", err)
}
// output.ResourceChanges
if p.Changes != nil {
output.ResourceChanges, err = MarshalResourceChanges(p.Changes.Resources, schemas)
if err != nil {
return nil, fmt.Errorf("error in marshaling resource changes: %s", err)
}
}
if p.DeferredResources != nil {
output.DeferredChanges, err = MarshalDeferredResourceChanges(p.DeferredResources, schemas)
if err != nil {
return nil, fmt.Errorf("error in marshaling deferred resource changes: %s", err)
}
}
if p.DeferredActionInvocations != nil {View on GitHub (pinned to c9def3e214)
Solutions
- Inspect the inner error (often 618/619) to see which step/key failed.
- Report as a renderer bug if it occurs on a common attribute type.
- As a workaround, isolate the configuration/reference that produces the problematic attribute path and avoid it.
Defensive patterns
Strategy: try-catch
Try / catch
out, err := jsonplan.Marshal(config, plan, sf, schemas)
if err != nil {
// inner error is usually a path-step marshal failure (618/619);
// capture it for diagnostics rather than ignoring.
return err
} Prevention
- Report path-encoding failures with the full path so the offending step is identifiable.
- Avoid configurations that build relevant-attribute paths through exotic key types.
When it happens
Trigger: plan.RelevantAttributes contains an entry whose path has an unsupported step type or an index key/attribute name that cannot marshal. Reached on every full Marshal call when relevant attributes exist.
Common situations: Rare. Usually tied to a path-encoding bug or an exotic value type used as an index key in a cross-resource reference; can follow internal changes to how relevant attributes are recorded.
Related errors
- Failed to marshal index step key %#v: %s
- Failed to marshal get attr step name %#v: %s
- error in marshalPlanVariables: %s
- error in marshalPlannedValues: %s
- error in marshaling resource drift: %s
AI-assisted analysis of hashicorp/terraform@c9def3e214 (2026-08-07).
Data as JSON: /api/errors/fae6b5bbc1df4cf7.
Report an issue: GitHub.