hashicorp/terraform · error
error in marshaling deferred resource changes
Error message
error in marshaling deferred resource changes: %s
What it means
Top-level propagation error from Marshal: MarshalDeferredResourceChanges failed on p.DeferredResources. Deferred changes are decoded/rendered like normal resource changes, so failures are schema/decode related, specific to the deferred set.
Solutions
- Read the wrapped error for the failing deferred resource.
- Upgrade Terraform to a version matching the plan's deferral feature set.
- Regenerate the plan with current providers.
- Ensure providers for deferred resource types are initialized.
Defensive patterns
Strategy: try-catch
Try / catch
if err := MarshalDeferredResourceChanges(p.DeferredResources, schemas); err != nil {
// inspect wrapped cause; deferred changes use the same schemas as normal ones
return err
} Prevention
- Use a Terraform version that supports deferred actions when rendering such plans.
- Keep providers for deferred resource types initialized.
When it happens
Trigger: A deferred resource change references a provider schema missing at render time, or its values fail decode/marshal. Deferred changes are a newer plan feature, so version skew is a common cause.
Common situations: Rendering a plan with deferred actions on a Terraform that does not fully support them; provider schema changed after deferral.
Related errors
- error in marshaling deferred action invocations
- error in marshaling resource changes
- error in marshaling resource drift
- error in marshaling output changes
- error in marshalPlannedValues
AI-assisted analysis of hashicorp/terraform@d32a084675 (2026-08-11).
Data as JSON: /api/errors/bab7673a646087fa.
Report an issue: GitHub.
Appendix: source
Thrown at internal/command/jsonplan/plan.go:312
}
}
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 {
output.DeferredActionInvocations, err = MarshalDeferredActionInvocations(p.DeferredActionInvocations, schemas)
if err != nil {
return nil, fmt.Errorf("error in marshaling deferred action invocations: %s", err)
}
}
// output.OutputChanges
if output.OutputChanges, err = MarshalOutputChanges(p.Changes); err != nil {
return nil, fmt.Errorf("error in marshaling output changes: %s", err)
}
// output.Checks
if p.Checks != nil && p.Checks.ConfigResults.Len() > 0 {
output.Checks = jsonchecks.MarshalCheckStates(p.Checks)View on GitHub (pinned to d32a084675)