{"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":"console","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/c9def3e214014c1188faabfc4a5bde5095139765/internal/command/jsonplan/plan.go#L1064-L1087","documentation":"Thrown by encodePath() in the JSON plan renderer when a cty.Path step is neither a cty.IndexStep nor a cty.GetAttrStep. The HCL cty library only defines those two concrete step types, so reaching the default branch means the path came from an internal caller that constructed an unsupported or custom step type. It is a defensive guard against an internal invariant violation rather than a user-facing condition.","triggerScenarios":"Produced only when Terraform's plan-to-JSON encoder (jsonplan.encodePath) iterates path steps while serializing change/sensitive paths and encounters a step value whose Go type is not cty.IndexStep or cty.GetAttrStep. This happens during `terraform show -json <plan>` or programmatic plan rendering when a provider or internal subsystem emitted a malformed cty.Path.","commonSituations":"Almost always indicates a bug in Terraform Core or a provider SDK that introduced a new/non-standard cty.Path step type. Seen in prerelease builds, experimental custom step types, or forks of cty. Not triggerable by normal HCL configuration.","solutions":["Upgrade Terraform Core to the latest stable release — this is an internal bug, not a config issue.","If using an experimental or forked cty/provider SDK, revert to the upstream versions that only emit IndexStep/GetAttrStep.","File a bug report against hashicorp/terraform with the plan file and the reproducing `terraform show -json` command.","As a workaround, render the plan in human-readable form (`terraform show <plan>`) instead of JSON until the bug is fixed."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":"// Validate all path steps are a supported cty step type before serializing.\nfunc isSupportedPath(p cty.Path) bool {\n    for _, step := range p {\n        switch step.(type) {\n        case cty.IndexStep, cty.GetAttrStep:\n        default:\n            return false\n        }\n    }\n    return true\n}","tryCatchPattern":"if _, err := jsonplan.EncodePath(path); err != nil {\n    // Fall back to non-JSON plan rendering; this is an internal Terraform bug.\n    log.Printf(\"skip json path encoding, unsupported step: %v\", err)\n}","preventionTips":["Do not introduce custom cty.Path step types; only IndexStep and GetAttrStep are serializable.","Pin Terraform Core to a stable release in CI rather than prerelease builds.","Regression-test plan JSON rendering whenever you fork cty or add new path constructs."],"tags":["terraform","cty","jsonplan","internal-bug","serialization"],"analyzedSha":"c9def3e214014c1188faabfc4a5bde5095139765","analyzedAt":"2026-08-07T15:39:49.278Z","schemaVersion":2},"datasetVersion":"2026-08-07T20:17:04.800Z"}