{"record":{"id":"7b070aef3da9cf98","repo":"hashicorp/terraform","slug":"resource-s-has-an-unsupported-mode-s-7b070a","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/plan.go","lineNumber":611,"sourceCode":"\tif key != nil {\n\t\tif key == addrs.WildcardKey {\n\t\t\t// The wildcard key should only be set for a deferred instance.\n\t\t\tr.IndexUnknown = true\n\t\t} else {\n\t\t\tvalue := key.Value()\n\t\t\tif r.Index, err = ctyjson.Marshal(value, value.Type()); err != nil {\n\t\t\t\treturn r, err\n\t\t\t}\n\t\t}\n\t}\n\n\tswitch addr.Resource.Resource.Mode {\n\tcase addrs.ManagedResourceMode:\n\t\tr.Mode = jsonstate.ManagedResourceMode\n\tcase addrs.DataResourceMode:\n\t\tr.Mode = jsonstate.DataResourceMode\n\tdefault:\n\t\treturn r, fmt.Errorf(\"resource %s has an unsupported mode %s\", r.Address, addr.Resource.Resource.Mode.String())\n\t}\n\tr.ModuleAddress = addr.Module.String()\n\tr.Name = addr.Resource.Resource.Name\n\tr.Type = addr.Resource.Resource.Type\n\tr.ProviderName = rc.ProviderAddr.Provider.String()\n\n\tswitch rc.ActionReason {\n\tcase plans.ResourceInstanceChangeNoReason:\n\t\tr.ActionReason = \"\" // will be omitted in output\n\tcase plans.ResourceInstanceReplaceBecauseCannotUpdate:\n\t\tr.ActionReason = ResourceInstanceReplaceBecauseCannotUpdate\n\tcase plans.ResourceInstanceReplaceBecauseTainted:\n\t\tr.ActionReason = ResourceInstanceReplaceBecauseTainted\n\tcase plans.ResourceInstanceReplaceByRequest:\n\t\tr.ActionReason = ResourceInstanceReplaceByRequest\n\tcase plans.ResourceInstanceReplaceByTriggers:\n\t\tr.ActionReason = ResourceInstanceReplaceByTriggers\n\tcase plans.ResourceInstanceDeleteBecauseNoResourceConfig:","sourceCodeStart":593,"sourceCodeEnd":629,"githubUrl":"https://github.com/hashicorp/terraform/blob/c9def3e214014c1188faabfc4a5bde5095139765/internal/command/jsonplan/plan.go#L593-L629","documentation":"marshalResourceChange switches on addr.Resource.Resource.Mode; only ManagedResourceMode and DataResourceMode are handled. Any other mode hits the default. The addrs package only defines these two modes for resources, so this is effectively an internal invariant violation rather than a configuration issue.","triggerScenarios":"A resource instance whose mode is neither managed nor data is present in the changes. Only reachable if a new resource mode is added to addrs without renderer support, or via a custom build.","commonSituations":"Very rare. Indicates a Terraform core change introducing a new resource mode not yet handled by jsonplan, or a fork with an extra mode.","solutions":["Report as an internal bug; it is not user-fixable through HCL.","Ensure you are using a single consistent, released Terraform build.","If maintaining a fork that added a mode, add a case in plan.go:605."],"exampleFix":null,"handlingStrategy":"type-guard","validationCode":null,"typeGuard":"func supportedResourceMode(m addrs.ResourceMode) bool {\n    return m == addrs.ManagedResourceMode || m == addrs.DataResourceMode\n}\n\n// use before marshaling\nfor _, rc := range plan.Changes.Resources {\n    if !supportedResourceMode(rc.Addr.Resource.Resource.Mode) {\n        return fmt.Errorf(\"unsupported resource mode %s for %s\", rc.Addr.Resource.Resource.Mode, rc.Addr)\n    }\n}","tryCatchPattern":null,"preventionTips":["Treat this as a bug, not a runtime condition.","Use a single consistent Terraform build so addrs and jsonplan agree on modes.","If forking to add a resource mode, add a case in plan.go:605 in the same change."],"tags":["resource","mode","internal","invariant"],"analyzedSha":"c9def3e214014c1188faabfc4a5bde5095139765","analyzedAt":"2026-08-07T15:39:49.278Z","schemaVersion":2},"datasetVersion":"2026-08-07T20:17:04.800Z"}