hashicorp/terraform · error
error in marshaling resource changes: %s
Error message
error in marshaling resource changes: %s
What it means
Top-level wrapper: serializing the primary resource_changes list via MarshalResourceChanges(p.Changes.Resources, ...) failed. The inner error usually comes from marshalResourceChange and surfaces as 615 (no schema), 616 (unsupported mode), 617 (unsupported action reason), or a decode/ctyjson error.
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 c9def3e214)
Solutions
- Read the inner error to find the offending resource address and specific cause.
- Run `terraform init` to install/pin the correct provider versions.
- Regenerate the plan with a Terraform version consistent with the state.
Defensive patterns
Strategy: try-catch
Try / catch
changes, err := jsonplan.MarshalResourceChanges(plan.Changes.Resources, schemas)
if err != nil {
// the inner error names the offending resource; surface it to the user
return fmt.Errorf("marshal resource changes: %w", err)
} Prevention
- Install and pin all providers with `terraform init` before rendering.
- Match provider versions between plan creation and rendering.
- Treat a 'no schema found' inner error as a missing/mismatched provider.
When it happens
Trigger: Reached on every full Marshal call when p.Changes != nil. Any planned resource change that fails to marshal aborts the whole render and is wrapped here.
Common situations: Missing provider schema for a planned resource; provider version mismatch; a resource mode/action reason from a newer Terraform; corrupted plan or state.
Related errors
- error in marshaling deferred resource changes: %s
- error in marshalPlanVariables: %s
- error in marshalPlannedValues: %s
- error in marshaling resource drift: %s
- error marshaling relevant attributes for external changes: %
AI-assisted analysis of hashicorp/terraform@c9def3e214 (2026-08-07).
Data as JSON: /api/errors/d71ca8eb8af061c4.
Report an issue: GitHub.