{"record":{"id":"d44f94ca22613aed","repo":"hashicorp/terraform","slug":"unsupported-path-step-v-t","errorCode":null,"errorMessage":"Unsupported path step %#v (%t)","messagePattern":"Unsupported path step %#v \\(%t\\)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/command/jsonplan/plan.go","lineNumber":1082,"sourceCode":"\nfunc encodePath(path cty.Path) (json.RawMessage, error) {\n\tsteps := make([]json.RawMessage, 0, len(path))\n\tfor _, step := range path {\n\t\tswitch s := step.(type) {\n\t\tcase cty.IndexStep:\n\t\t\tkey, err := ctyjson.Marshal(s.Key, s.Key.Type())\n\t\t\tif err != nil {\n\t\t\t\treturn nil, fmt.Errorf(\"Failed to marshal index step key %#v: %s\", s.Key, err)\n\t\t\t}\n\t\t\tsteps = append(steps, key)\n\t\tcase cty.GetAttrStep:\n\t\t\tname, err := json.Marshal(s.Name)\n\t\t\tif err != nil {\n\t\t\t\treturn nil, fmt.Errorf(\"Failed to marshal get attr step name %#v: %s\", s.Name, err)\n\t\t\t}\n\t\t\tsteps = append(steps, name)\n\t\tdefault:\n\t\t\treturn nil, fmt.Errorf(\"Unsupported path step %#v (%t)\", step, step)\n\t\t}\n\t}\n\treturn json.Marshal(steps)\n}\n","sourceCodeStart":1064,"sourceCodeEnd":1087,"githubUrl":"https://github.com/hashicorp/terraform/blob/d32a084675427f5ac3f7d2868578ef8b2c1dc525/internal/command/jsonplan/plan.go#L1064-L1087","documentation":"Thrown by jsonplan.encodePath in the default branch of the path-step type switch. cty officially defines only two path step types, cty.IndexStep and cty.GetAttrStep. Any other concrete type implementing cty.PathValue (or a nil step) reaches default and aborts serialization, because the JSON path format has no representation for it.","triggerScenarios":"A cty.Path is constructed with a step type other than IndexStep/GetAttrStep; a nil entry in the path slice; a newer cty version introduced a step type Terraform's encoder does not know.","commonSituations":"Terraform built against an incompatible cty version; third-party code that builds custom cty.Path values and passes them into the JSON plan APIs.","solutions":["Align the Terraform and cty library versions.","If you construct paths programmatically, ensure only IndexStep and GetAttrStep are used before passing to jsonplan.","Report the step type (%T) printed in the message upstream."],"exampleFix":"// before\ndefault:\n\treturn nil, fmt.Errorf(\"Unsupported path step %#v (%t)\", step, step)\n\n// after (skip nil/unknown steps or add the new step type's JSON form)\ndefault:\n\tif step == nil {\n\t\tcontinue\n\t}\n\treturn nil, fmt.Errorf(\"unsupported path step %T\", step)","handlingStrategy":"type-guard","validationCode":null,"typeGuard":"func isKnownPathStep(s cty.PathStep) bool {\n    switch s.(type) {\n    case cty.IndexStep, cty.GetAttrStep:\n        return true\n    }\n    return false\n}\n\nfor _, s := range path {\n    if !isKnownPathStep(s) {\n        return fmt.Errorf(\"refusing to encode path with unsupported step %T\", s)\n    }\n}","tryCatchPattern":null,"preventionTips":["Only construct cty.Path values from IndexStep and GetAttrStep when feeding them to jsonplan.","Pin Terraform and the cty dependency to compatible versions.","Filter out nil or custom path steps before serialization."],"tags":["terraform","json-plan","cty","path-encoding","type-switch"],"backgroundTag":null,"analyzedSha":"d32a084675427f5ac3f7d2868578ef8b2c1dc525","analyzedAt":"2026-08-11T18:43:52.779Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}