hashicorp/terraform · error
error in marshaling resource changes
Error message
error in marshaling resource changes: %s
What it means
Top-level propagation error from Marshal: MarshalResourceChanges failed on p.Changes.Resources (the full set of planned resource changes). The wrapped error identifies which resource change failed to decode/render.
Solutions
- Read the wrapped error for the failing resource address and cause (often a 619-style missing schema).
- Re-run `terraform init` and `terraform plan`.
- Align Terraform and provider versions across environments.
- Inspect .terraform.lock.hcl for provider version divergence.
Defensive patterns
Strategy: validation
Validate before calling
// Verify each planned resource change has a schema before marshaling.
func changesSchemasOk(changes *plans.ChangesSrc, schemas *terraform.Schemas) error {
for _, rc := range changes.Resources {
s := schemas.ResourceTypeConfig(rc.ProviderAddr.Provider, rc.Addr.Resource.Resource.Mode, rc.Addr.Resource.Resource.Type)
if s.Body == nil {
return fmt.Errorf("resource %%s has no schema", rc.Addr)
}
}
return nil
} Prevention
- Run `terraform init` before rendering so all resource schemas are present.
- Align provider versions across plan and render environments via .terraform.lock.hcl.
When it happens
Trigger: A resource instance change references a missing or incompatible provider schema, or its before/after values cannot be decoded or marshaled (type drift, marks).
Common situations: Provider upgrade/downgrade between plan and render; corrupted plan; resources of a type the current provider no longer exposes.
Related errors
- error in marshaling deferred resource changes
- error in marshaling resource drift
- error in marshaling deferred action invocations
- error in marshaling output changes
- error in marshalPlannedValues
AI-assisted analysis of hashicorp/terraform@d32a084675 (2026-08-11).
Data as JSON: /api/errors/d71ca8eb8af061c4.
Report an issue: GitHub.
Appendix: source
Thrown at internal/command/jsonplan/plan.go:305
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 {
output.DeferredActionInvocations, err = MarshalDeferredActionInvocations(p.DeferredActionInvocations, schemas)
if err != nil {
return nil, fmt.Errorf("error in marshaling deferred action invocations: %s", err)
}
}
// output.OutputChangesView on GitHub (pinned to d32a084675)