{"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":"console","errorClass":null,"httpStatus":null,"severity":"critical","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/d32a084675427f5ac3f7d2868578ef8b2c1dc525/internal/command/jsonconfig/config.go#L470-L506","documentation":"Thrown by marshalResources when a configured resource's Mode is neither addrs.ManagedResourceMode nor addrs.DataResourceMode. The resource address and the unexpected mode string are included. This indicates an internal/state divergence: the configs layer should only ever produce managed or data resources.","triggerScenarios":"A resource in the loaded configuration carries a mode value outside the two valid cases. In practice unreachable through HCL authoring; would arise from a programmatic/buggy config load or an internal addrs package change introducing a new mode not handled here.","commonSituations":"Terraform internal bug; mismatched versions between addrs and configs packages; custom builds that extend ResourceMode without updating marshalResources.","solutions":["Report as a Terraform bug with the config and version, since HCL authoring cannot produce other modes.","Ensure you are running a released, mutually-consistent Terraform build (not a partial custom build).","Remove recently added custom patches to addrs/configs and use official binaries."],"exampleFix":null,"handlingStrategy":"type-guard","validationCode":"// Guard before marshaling: only marshal known modes.\nfunc supportedMode(m addrs.ResourceMode) bool {\n    return m == addrs.ManagedResourceMode || m == addrs.DataResourceMode\n}","typeGuard":"func isValidResourceMode(m addrs.ResourceMode) bool {\n    return m == addrs.ManagedResourceMode || m == addrs.DataResourceMode\n}","tryCatchPattern":null,"preventionTips":["Use official Terraform builds; do not mix addrs/configs versions.","Treat this error as a bug — report it with the config.","Avoid patching ResourceMode enums without updating marshalResources."],"tags":["terraform-internal","jsonconfig","resource-mode","bug"],"backgroundTag":null,"analyzedSha":"d32a084675427f5ac3f7d2868578ef8b2c1dc525","analyzedAt":"2026-08-11T18:43:52.779Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}