{"record":{"id":"d71ca8eb8af061c4","repo":"hashicorp/terraform","slug":"error-in-marshaling-resource-changes-s","errorCode":null,"errorMessage":"error in marshaling resource changes: %s","messagePattern":"error in marshaling resource changes: (.+?)","errorType":"console","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/command/jsonplan/plan.go","lineNumber":305,"sourceCode":"\t\t\t\t\tdriftedResources = append(driftedResources, dr)\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\toutput.ResourceDrift, err = MarshalResourceChanges(driftedResources, schemas)\n\t\tif err != nil {\n\t\t\treturn nil, fmt.Errorf(\"error in marshaling resource drift: %s\", err)\n\t\t}\n\t}\n\n\tif err := output.marshalRelevantAttrs(p); err != nil {\n\t\treturn nil, fmt.Errorf(\"error marshaling relevant attributes for external changes: %s\", err)\n\t}\n\n\t// output.ResourceChanges\n\tif p.Changes != nil {\n\t\toutput.ResourceChanges, err = MarshalResourceChanges(p.Changes.Resources, schemas)\n\t\tif err != nil {\n\t\t\treturn nil, fmt.Errorf(\"error in marshaling resource changes: %s\", err)\n\t\t}\n\t}\n\n\tif p.DeferredResources != nil {\n\t\toutput.DeferredChanges, err = MarshalDeferredResourceChanges(p.DeferredResources, schemas)\n\t\tif err != nil {\n\t\t\treturn nil, fmt.Errorf(\"error in marshaling deferred resource changes: %s\", err)\n\t\t}\n\t}\n\n\tif p.DeferredActionInvocations != nil {\n\t\toutput.DeferredActionInvocations, err = MarshalDeferredActionInvocations(p.DeferredActionInvocations, schemas)\n\t\tif err != nil {\n\t\t\treturn nil, fmt.Errorf(\"error in marshaling deferred action invocations: %s\", err)\n\t\t}\n\t}\n\n\t// output.OutputChanges","sourceCodeStart":287,"sourceCodeEnd":323,"githubUrl":"https://github.com/hashicorp/terraform/blob/d32a084675427f5ac3f7d2868578ef8b2c1dc525/internal/command/jsonplan/plan.go#L287-L323","documentation":"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.","triggerScenarios":"A resource instance change references a missing or incompatible provider schema, or its before/after values cannot be decoded or marshaled (type drift, marks).","commonSituations":"Provider upgrade/downgrade between plan and render; corrupted plan; resources of a type the current provider no longer exposes.","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."],"exampleFix":null,"handlingStrategy":"validation","validationCode":"// Verify each planned resource change has a schema before marshaling.\nfunc changesSchemasOk(changes *plans.ChangesSrc, schemas *terraform.Schemas) error {\n    for _, rc := range changes.Resources {\n        s := schemas.ResourceTypeConfig(rc.ProviderAddr.Provider, rc.Addr.Resource.Resource.Mode, rc.Addr.Resource.Resource.Type)\n        if s.Body == nil {\n            return fmt.Errorf(\"resource %%s has no schema\", rc.Addr)\n        }\n    }\n    return nil\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Run `terraform init` before rendering so all resource schemas are present.","Align provider versions across plan and render environments via .terraform.lock.hcl."],"tags":["go","terraform","plan","resource-changes","error-wrapping","jsonplan"],"backgroundTag":null,"analyzedSha":"d32a084675427f5ac3f7d2868578ef8b2c1dc525","analyzedAt":"2026-08-11T18:43:52.779Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}