{"record":{"id":"feee96842477be5a","repo":"hashicorp/terraform","slug":"resource-s-has-an-unsupported-mode-s","errorCode":null,"errorMessage":"resource %s has an unsupported mode %s","messagePattern":"resource (.+?) has an unsupported mode (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/command/jsonconfig/config.go","lineNumber":488,"sourceCode":"\nfunc marshalResources(resources map[string]*configs.Resource, schemas *terraform.Schemas, moduleAddr string) ([]resource, error) {\n\tvar rs []resource\n\tfor _, v := range resources {\n\t\tproviderConfigKey := opaqueProviderKey(v.ProviderConfigAddr().StringCompact(), moduleAddr)\n\t\tr := resource{\n\t\t\tAddress:           v.Addr().String(),\n\t\t\tType:              v.Type,\n\t\t\tName:              v.Name,\n\t\t\tProviderConfigKey: providerConfigKey,\n\t\t}\n\n\t\tswitch v.Mode {\n\t\tcase addrs.ManagedResourceMode:\n\t\t\tr.Mode = \"managed\"\n\t\tcase addrs.DataResourceMode:\n\t\t\tr.Mode = \"data\"\n\t\tdefault:\n\t\t\treturn rs, fmt.Errorf(\"resource %s has an unsupported mode %s\", r.Address, v.Mode.String())\n\t\t}\n\n\t\tcExp := marshalExpression(v.Count)\n\t\tif !cExp.Empty() {\n\t\t\tr.CountExpression = &cExp\n\t\t} else {\n\t\t\tfExp := marshalExpression(v.ForEach)\n\t\t\tif !fExp.Empty() {\n\t\t\t\tr.ForEachExpression = &fExp\n\t\t\t}\n\t\t}\n\n\t\tschema := schemas.ResourceTypeConfig(\n\t\t\tv.Provider,\n\t\t\tv.Mode,\n\t\t\tv.Type,\n\t\t)\n\t\tif schema.Body == nil {","sourceCodeStart":470,"sourceCodeEnd":506,"githubUrl":"https://github.com/hashicorp/terraform/blob/c9def3e214014c1188faabfc4a5bde5095139765/internal/command/jsonconfig/config.go#L470-L506","documentation":"Returned by jsonconfig.marshalResources when a configs.Resource has a Mode that is neither ManagedResourceMode nor DataResourceMode (config.go:482-489). Resource modes are an enumerated set, so reaching the default branch means an unhandled mode value. The message names the resource address and the offending mode string, and is treated as an internal invariant violation.","triggerScenarios":"Producing JSON config output (`terraform show -json` / jsonconfig.Marshal) for a configuration whose resources carry a mode the marshaler does not recognize — e.g. a future Terraform version introduces a new resource mode (such as action/ephemeral) before the jsonconfig package is updated, or internal state/config is constructed with an out-of-range mode value.","commonSituations":"Version skew: running a newer terraform state/config with an older build of the CLI; custom tooling that fabricates configs.Resource values with invalid modes; in-development features that add modes without updating marshalers.","solutions":["Upgrade terraform CLI to a version whose jsonconfig knows about the resource mode in use.","Downgrade the configuration/state to a version compatible with the running CLI.","If developing a new resource mode, add the case to marshalResources before exercising show -json.","Report as a Terraform bug with the resource address and mode string from the error."],"exampleFix":null,"handlingStrategy":"type-guard","validationCode":"// Before marshalling, confirm all resource modes are known to the marshaler.\nfor _, r := range module.Resources() {\n    if r.Mode != addrs.ManagedResourceMode && r.Mode != addrs.DataResourceMode {\n        return fmt.Errorf(\"unsupported resource mode %q on %s; upgrade terraform\", r.Mode, r.Addr())\n    }\n}","typeGuard":"// isMarshalableResourceMode narrows to the modes jsonconfig supports.\nfunc isMarshalableResourceMode(m addrs.ResourceMode) bool {\n    return m == addrs.ManagedResourceMode || m == addrs.DataResourceMode\n}","tryCatchPattern":null,"preventionTips":["Keep the terraform CLI version in sync with the config/state version that defines resource modes.","When adding a new resource mode internally, update marshalResources before shipping."],"tags":["terraform-jsonconfig","schema","resource-mode","internal-bug","version-skew"],"analyzedSha":"c9def3e214014c1188faabfc4a5bde5095139765","analyzedAt":"2026-08-07T15:39:49.278Z","schemaVersion":2},"datasetVersion":"2026-08-07T20:17:04.800Z"}