{"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":"validation","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/d32a084675427f5ac3f7d2868578ef8b2c1dc525/internal/command/jsonplan/values.go#L173-L209","documentation":"Thrown by jsonplan while computing the planned resource values (the values.go path that builds the 'resource_changes'/'planned_values' payload). The switch over r.Addr.Resource.Resource.Mode again only handles Managed and Data; ephemeral, list, invalid, or any future mode falls to default. Functionally the values-side twin of error 620.","triggerScenarios":"An ephemeral/list/invalid-mode resource is fed into the planned-values computation; a future ResourceMode constant is added without updating this switch; corrupted plan data with Mode==0.","commonSituations":"Same as 620: dev/internal builds routing unsupported modes into JSON plan serialization; cross-version plan consumption.","solutions":["Upgrade Terraform so the planned-values serializer recognizes the resource mode.","Filter ephemeral/list resources out before invoking MarshalPlannedResourceChanges.","If extending Terraform, add the case or an explicit early skip in internal/command/jsonplan/values.go.","Report upstream with the address and mode string from the message."],"exampleFix":"// before\nswitch r.Addr.Resource.Resource.Mode {\ncase addrs.ManagedResourceMode:\n\tresource.Mode = \"managed\"\ncase addrs.DataResourceMode:\n\tresource.Mode = \"data\"\ndefault:\n\treturn nil, fmt.Errorf(\"resource %s has an unsupported mode %s\", r.Addr.String(), r.Addr.Resource.Resource.Mode.String())\n}\n\n// after (skip non-persistent modes rather than aborting)\ncase addrs.EphemeralResourceMode, addrs.ListResourceMode:\n\tcontinue","handlingStrategy":"validation","validationCode":"// Mirror of the serializer's own switch: only managed/data are JSON-encodable.\nfunc isJSONPlannableMode(m addrs.ResourceMode) bool {\n    return m == addrs.ManagedResourceMode || m == addrs.DataResourceMode\n}\n\nfor _, r := range resources {\n    if !isJSONPlannableMode(r.Addr.Resource.Resource.Mode) {\n        continue\n    }\n    // ... compute planned values\n}","typeGuard":"func isPlannableResource(r *plans.ResourceChange) bool {\n    switch r.Addr.Resource.Resource.Mode {\n    case addrs.ManagedResourceMode, addrs.DataResourceMode:\n        return true\n    }\n    return false\n}","tryCatchPattern":null,"preventionTips":["Exclude ephemeral and list resources before invoking planned-values marshaling.","Keep mode switches in jsonplan/values.go and jsonplan/plan.go consistent.","When adding a ResourceMode, update both the change and values serializers together."],"tags":["terraform","json-plan","resource-mode","serialization","enum-exhaustiveness"],"backgroundTag":null,"analyzedSha":"d32a084675427f5ac3f7d2868578ef8b2c1dc525","analyzedAt":"2026-08-11T18:43:52.779Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}