{"record":{"id":"1fd19558046c639b","repo":"hashicorp/terraform","slug":"error-in-marshaling-resource-drift-s","errorCode":null,"errorMessage":"error in marshaling resource drift: %s","messagePattern":"error in marshaling resource drift: (.+?)","errorType":"console","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/command/jsonplan/plan.go","lineNumber":293,"sourceCode":"\t// output.ResourceDrift\n\tif len(p.DriftedResources) > 0 {\n\t\t// In refresh-only mode, we render all resources marked as drifted,\n\t\t// including those which have moved without other changes. In other plan\n\t\t// modes, move-only changes will be included in the planned changes, so\n\t\t// we skip them here.\n\t\tvar driftedResources []*plans.ResourceInstanceChangeSrc\n\t\tif p.UIMode == plans.RefreshOnlyMode {\n\t\t\tdriftedResources = p.DriftedResources\n\t\t} else {\n\t\t\tfor _, dr := range p.DriftedResources {\n\t\t\t\tif dr.Action != plans.NoOp {\n\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 {","sourceCodeStart":275,"sourceCodeEnd":311,"githubUrl":"https://github.com/hashicorp/terraform/blob/d32a084675427f5ac3f7d2868578ef8b2c1dc525/internal/command/jsonplan/plan.go#L275-L311","documentation":"Top-level propagation error from Marshal: MarshalResourceChanges failed on the drifted-resources subset. Drifted resources are decoded and rendered like other resource changes, so the failure is usually schema or decode related.","triggerScenarios":"A drifted resource instance references a provider schema that is missing or incompatible at render time, or its before/after values fail to decode.","commonSituations":"Drift detected against resources whose provider was since changed/removed; refresh-only mode plans rendered with a different provider set.","solutions":["Read the wrapped error for the specific resource address.","Ensure the provider for the drifted resource type is initialized.","Regenerate the plan so drift reflects current schemas.","If the resource was removed from config/provider intentionally, refresh state to clear drift."],"exampleFix":null,"handlingStrategy":"validation","validationCode":"// Confirm each drifted resource has a usable schema before marshaling.\nfunc driftedSchemasOk(drifted []*plans.ResourceInstanceChangeSrc, schemas *terraform.Schemas) error {\n    for _, d := range drifted {\n        s := schemas.ResourceTypeConfig(d.ProviderAddr.Provider, d.Addr.Resource.Resource.Mode, d.Addr.Resource.Resource.Type)\n        if s.Body == nil {\n            return fmt.Errorf(\"drifted resource %%s has no schema\", d.Addr)\n        }\n    }\n    return nil\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Keep providers for all in-state resources initialized.","Refresh state to clear drift for resources removed from config/provider."],"tags":["go","terraform","plan","drift","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"}