hashicorp/terraform · error
Unsupported path step %#v (%t)
Error message
Unsupported path step %#v (%t)
What it means
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.
Source
Thrown at internal/command/jsonplan/plan.go:1082
func encodePath(path cty.Path) (json.RawMessage, error) {
steps := make([]json.RawMessage, 0, len(path))
for _, step := range path {
switch s := step.(type) {
case cty.IndexStep:
key, err := ctyjson.Marshal(s.Key, s.Key.Type())
if err != nil {
return nil, fmt.Errorf("Failed to marshal index step key %#v: %s", s.Key, err)
}
steps = append(steps, key)
case cty.GetAttrStep:
name, err := json.Marshal(s.Name)
if err != nil {
return nil, fmt.Errorf("Failed to marshal get attr step name %#v: %s", s.Name, err)
}
steps = append(steps, name)
default:
return nil, fmt.Errorf("Unsupported path step %#v (%t)", step, step)
}
}
return json.Marshal(steps)
}
View on GitHub (pinned to c9def3e214)
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.
Defensive patterns
Strategy: try-catch
Type guard
// Validate all path steps are a supported cty step type before serializing.
func isSupportedPath(p cty.Path) bool {
for _, step := range p {
switch step.(type) {
case cty.IndexStep, cty.GetAttrStep:
default:
return false
}
}
return true
} Try / catch
if _, err := jsonplan.EncodePath(path); err != nil {
// Fall back to non-JSON plan rendering; this is an internal Terraform bug.
log.Printf("skip json path encoding, unsupported step: %v", err)
} Prevention
- 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.
When it happens
Trigger: 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.
Common situations: 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.
Related errors
- resource %s has an unsupported mode %s
- %s: cannot serialize value marked as %#v for inclusion in a
- invalid collection length: %s
- failed to read state: %w
- cannot serialize updated credentials file: %s
AI-assisted analysis of hashicorp/terraform@c9def3e214 (2026-08-07).
Data as JSON: /api/errors/d44f94ca22613aed.
Report an issue: GitHub.