{"record":{"id":"d1a282c5d5d5ff1e","repo":"hashicorp/terraform","slug":"saved-backend-configuration-is-invalid-w","errorCode":null,"errorMessage":"saved backend configuration is invalid: %w","messagePattern":"saved backend configuration is invalid: %w","errorType":"console","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/command/meta_backend.go","lineNumber":547,"sourceCode":"\n\t\t// The fully configured Pluggable is used as the instance of backend.Backend\n\t\tb = p\n\n\tdefault:\n\t\tsettings := plan.Backend\n\n\t\tf := backendInit.Backend(settings.Type)\n\t\tif f == nil {\n\t\t\tdiags = diags.Append(errBackendSavedUnknown{settings.Type})\n\t\t\treturn nil, diags\n\t\t}\n\t\tb = f()\n\t\tlog.Printf(\"[TRACE] Meta.BackendForLocalPlan: instantiated backend of type %T\", b)\n\n\t\tschema := b.ConfigSchema()\n\t\tconfigVal, err := settings.Config.Decode(schema.ImpliedType())\n\t\tif err != nil {\n\t\t\tdiags = diags.Append(fmt.Errorf(\"saved backend configuration is invalid: %w\", err))\n\t\t\treturn nil, diags\n\t\t}\n\n\t\tnewVal, validateDiags := b.PrepareConfig(configVal)\n\t\tdiags = diags.Append(validateDiags)\n\t\tif validateDiags.HasErrors() {\n\t\t\treturn nil, diags\n\t\t}\n\n\t\tconfigureDiags := b.Configure(newVal)\n\t\tdiags = diags.Append(configureDiags)\n\t\tif configureDiags.HasErrors() {\n\t\t\treturn nil, diags\n\t\t}\n\t}\n\n\t// If the backend supports CLI initialization, do it.\n\tif cli, ok := b.(backendrun.CLI); ok {","sourceCodeStart":529,"sourceCodeEnd":565,"githubUrl":"https://github.com/hashicorp/terraform/blob/c9def3e214014c1188faabfc4a5bde5095139765/internal/command/meta_backend.go#L529-L565","documentation":"Appended as a diagnostic in BackendForLocalPlan() (the classic backend branch) when settings.Config.Decode(schema.ImpliedType()) fails. The plan file stored a serialized backend configuration blob, and it cannot be decoded against the current backend's implied schema. The %w wraps the cty decode error. This means the plan file is internally inconsistent with the backend implementation present.","triggerScenarios":"Loading a saved plan whose embedded backend configuration was produced by a different version of the backend (schema changed), or the plan file itself is truncated/corrupted. Decode against the current backend's ConfigSchema().ImpliedType() yields a malformed-value error.","commonSituations":"Applying a plan created with an older Terraform/backend version after upgrading; a plan file edited or partially written by a crashed process; a backend plugin downgraded between plan and apply; copying a plan file across incompatible backend implementations.","solutions":["Regenerate the plan with the current Terraform and backend versions: `terraform plan -out=plan.tfplan`, then apply.","Ensure the same backend plugin version is installed at apply time as was used at plan time (re-run terraform init).","If the plan must be reused, align backend/terraform versions to those that created the plan.","Discard suspect plan files that may have been truncated by an interrupted process."],"exampleFix":"# before: applying plan from older terraform version\nterraform apply old-plan.tfplan\n# saved backend configuration is invalid\n# after: re-plan with current version\nterraform plan -out=plan.tfplan\nterraform apply plan.tfplan","handlingStrategy":"validation","validationCode":"// Reject plan files created by a different terraform/backend version before apply\nif planWasCreatedByDifferentVersion(planFile) {\n    log.Fatal(\"regenerate the plan with the current terraform/backend version\")\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Create and apply plans with the same Terraform and backend plugin versions.","Don't edit or partially copy plan files; treat them as opaque.","Re-run `terraform plan -out=...` after any backend or terraform upgrade."],"tags":["plan","backend","schema","decode","version-mismatch"],"analyzedSha":"c9def3e214014c1188faabfc4a5bde5095139765","analyzedAt":"2026-08-07T15:39:49.278Z","schemaVersion":2},"datasetVersion":"2026-08-07T21:17:07.882Z"}