hashicorp/terraform · error
error marshaling config
Error message
error marshaling config: %s
What it means
Top-level propagation error from Marshal: jsonconfig.Marshal failed while rendering the configuration snapshot embedded in the plan JSON. The wrapped error comes from the config marshaller and usually indicates a schema lookup or decode problem for a configured resource.
Solutions
- Read the wrapped error for the failing config block/resource type.
- Run `terraform init` to ensure providers and schemas are present.
- Update the provider lock file to a version that defines the resource type.
- Regenerate the plan after init.
Defensive patterns
Strategy: validation
Validate before calling
// Confirm each configured resource/data source has a schema before marshaling config.
func configSchemasOk(cfg *configs.Config, schemas *terraform.Schemas) error {
for _, r := range cfg.Module.ManagedResources {
s := schemas.ResourceTypeConfig(r.ProviderConfigAddr(), addrs.ManagedResourceMode, r.Type) // simplified
if s.Body == nil {
return fmt.Errorf("resource %%s has no schema", r.Addr())
}
}
return nil
} Prevention
- Run `terraform init` to load all provider schemas referenced by config.
- Update .terraform.lock.hcl when adopting new resource types.
When it happens
Trigger: A resource/data source in the config references a provider schema that is missing or incompatible, or a config block fails to decode against the provider schema.
Common situations: Provider not initialized; provider version in lock file predates a resource type used in config; cross-version rendering.
Related errors
- error in marshaling deferred action invocations
- error in marshaling deferred resource changes
- error in marshaling output changes
- error in marshaling resource changes
- error in marshaling resource drift
AI-assisted analysis of hashicorp/terraform@d32a084675 (2026-08-11).
Data as JSON: /api/errors/77eda3f84d904301.
Report an issue: GitHub.
Appendix: source
Thrown at internal/command/jsonplan/plan.go:344
}
// output.Checks
if p.Checks != nil && p.Checks.ConfigResults.Len() > 0 {
output.Checks = jsonchecks.MarshalCheckStates(p.Checks)
}
// output.PriorState
if sf != nil && !sf.State.Empty() {
output.PriorState, err = jsonstate.Marshal(sf, schemas)
if err != nil {
return nil, fmt.Errorf("error marshaling prior state: %s", err)
}
}
// output.Config
output.Config, err = jsonconfig.Marshal(config, schemas)
if err != nil {
return nil, fmt.Errorf("error marshaling config: %s", err)
}
// output.Changes.ActionInvocations
if p.Changes.ActionInvocations != nil {
if output.ActionInvocations, err = MarshalActionInvocations(p.Changes.ActionInvocations, schemas); err != nil {
return nil, fmt.Errorf("error marshaling action invocations: %s", err)
}
}
return json.Marshal(output)
}
func (p *plan) marshalPlanVariables(vars map[string]plans.DynamicValue, decls map[string]*configs.Variable) error {
p.Variables = make(variables, len(vars))
for k, v := range vars {
val, err := v.Decode(cty.DynamicPseudoType)
if err != nil {View on GitHub (pinned to d32a084675)