{"record":{"id":"fbd77361dde21a2c","repo":"hashicorp/terraform","slug":"resource-s-has-an-unsupported-mode-s-fbd773","errorCode":null,"errorMessage":"resource %s has an unsupported mode %s","messagePattern":"resource (.+?) has an unsupported mode (.+?)","errorType":"console","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/command/jsonplan/values.go","lineNumber":191,"sourceCode":"\t\tif r.Action == plans.Delete || r.Action == plans.Forget {\n\t\t\tcontinue\n\t\t}\n\n\t\tresource := resource{\n\t\t\tAddress:      r.Addr.String(),\n\t\t\tType:         r.Addr.Resource.Resource.Type,\n\t\t\tName:         r.Addr.Resource.Resource.Name,\n\t\t\tProviderName: r.ProviderAddr.Provider.String(),\n\t\t\tIndex:        r.Addr.Resource.Key,\n\t\t}\n\n\t\tswitch r.Addr.Resource.Resource.Mode {\n\t\tcase addrs.ManagedResourceMode:\n\t\t\tresource.Mode = \"managed\"\n\t\tcase addrs.DataResourceMode:\n\t\t\tresource.Mode = \"data\"\n\t\tdefault:\n\t\t\treturn nil, fmt.Errorf(\"resource %s has an unsupported mode %s\",\n\t\t\t\tr.Addr.String(),\n\t\t\t\tr.Addr.Resource.Resource.Mode.String(),\n\t\t\t)\n\t\t}\n\n\t\tschema := schemas.ResourceTypeConfig(\n\t\t\tr.ProviderAddr.Provider,\n\t\t\tr.Addr.Resource.Resource.Mode,\n\t\t\tresource.Type,\n\t\t)\n\t\tif schema.Body == nil {\n\t\t\treturn nil, fmt.Errorf(\"no schema found for %s\", r.Addr.String())\n\t\t}\n\t\tresource.SchemaVersion = uint64(schema.Version)\n\t\tchangeV, err := r.Decode(schema)\n\t\tif err != nil {\n\t\t\treturn nil, err\n\t\t}","sourceCodeStart":173,"sourceCodeEnd":209,"githubUrl":"https://github.com/hashicorp/terraform/blob/c9def3e214014c1188faabfc4a5bde5095139765/internal/command/jsonplan/values.go#L173-L209","documentation":"Thrown by the JSON plan values builder when a resource instance's address mode is neither addrs.ManagedResourceMode nor addrs.DataResourceMode. Terraform only defines those two resource modes, so the default branch of the switch is unreachable under normal operation and signals an internal inconsistency in the planned changes structure.","triggerScenarios":"Reached when jsonplan marshals planned resource changes (changes.ResourceInstance iteration) and r.Addr.Resource.Resource.Mode returns a value outside {managed, data}. Occurs during `terraform show -json <plan>` or `terraform plan -json` rendering for a resource whose mode string is empty or unknown.","commonSituations":"Points to a Terraform Core bug where a resource change was recorded with an uninitialized or custom Mode value. Occasionally seen with very new/preview resource mode features or corrupted in-memory plan objects. Not caused by ordinary HCL configuration errors.","solutions":["Upgrade to the latest stable Terraform release that is compatible with your provider versions.","Reproduce with `terraform plan` (non-JSON) to confirm the plan itself is valid; if it succeeds, the bug is in the JSON renderer.","Report the issue to hashicorp/terraform with the plan file and provider versions.","Regenerate the plan from scratch (`terraform plan -out=new.tfplan`) in case the plan file was produced by a mismatched/older Terraform binary."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":"// Confirm a resource address mode is renderable before JSON plan marshaling.\nfunc isRenderableMode(m addrs.ResourceMode) bool {\n    return m == addrs.ManagedResourceMode || m == addrs.DataResourceMode\n}","tryCatchPattern":"if _, err := jsonplan.MarshalPlannedResourceChange(r, schemas); err != nil {\n    // Render human-readable plan instead; surface as a Terraform-internal bug.\n    return err\n}","preventionTips":["Do not register custom resource modes; only managed and data are supported.","Keep provider SDK and Terraform Core versions in sync.","Validate planned changes render in both text and JSON form in tests."],"tags":["terraform","jsonplan","resource-mode","internal-bug","serialization"],"analyzedSha":"c9def3e214014c1188faabfc4a5bde5095139765","analyzedAt":"2026-08-07T15:39:49.278Z","schemaVersion":2},"datasetVersion":"2026-08-07T21:17:07.882Z"}