{"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":"exception","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/c9def3e214014c1188faabfc4a5bde5095139765/internal/command/jsonplan/plan.go#L275-L311","documentation":"Top-level wrapper: marshaling the resource_drift list (out-of-band changes found during refresh) via MarshalResourceChanges(p.DriftedResources, ...) failed. The inner error is typically a missing schema for one of the drifted resources.","triggerScenarios":"len(p.DriftedResources) > 0 and marshaling one drifted ResourceInstanceChangeSrc errors. In refresh-only mode all drifted resources are rendered; in other modes only non-NoOp drift is rendered.","commonSituations":"Drift detected on a resource whose provider is not installed at render time; refresh-only mode combined with a provider downgrade; state referencing a resource whose provider was removed.","solutions":["Inspect the inner error to find which drifted resource failed.","Install the provider for the drifted resource with `terraform init`.","Align provider versions between the run that detected drift and the render."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"out, err := jsonplan.Marshal(config, plan, sf, schemas)\nif err != nil && strings.Contains(err.Error(), \"marshaling resource drift\") {\n    // a drifted resource failed; ensure its provider is installed\n}\nreturn err","preventionTips":["Ensure providers for all resources present in state are installed before refresh/render.","Resolve drift on resources whose providers may be unavailable before rendering in refresh-only mode.","Run `terraform init` before any `terraform show -json` of a drifted plan."],"tags":["drift","marshal","provider"],"analyzedSha":"c9def3e214014c1188faabfc4a5bde5095139765","analyzedAt":"2026-08-07T15:39:49.278Z","schemaVersion":2},"datasetVersion":"2026-08-07T21:17:07.882Z"}