hashicorp/terraform · error
resource has an unsupported mode
Error message
resource %s has an unsupported mode %s
What it means
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.
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.
Example fix
// before
switch r.Addr.Resource.Resource.Mode {
case addrs.ManagedResourceMode:
resource.Mode = "managed"
case addrs.DataResourceMode:
resource.Mode = "data"
default:
return nil, fmt.Errorf("resource %s has an unsupported mode %s", r.Addr.String(), r.Addr.Resource.Resource.Mode.String())
}
// after (skip non-persistent modes rather than aborting)
case addrs.EphemeralResourceMode, addrs.ListResourceMode:
continue Defensive patterns
Strategy: validation
Validate before calling
// Mirror of the serializer's own switch: only managed/data are JSON-encodable.
func isJSONPlannableMode(m addrs.ResourceMode) bool {
return m == addrs.ManagedResourceMode || m == addrs.DataResourceMode
}
for _, r := range resources {
if !isJSONPlannableMode(r.Addr.Resource.Resource.Mode) {
continue
}
// ... compute planned values
} Type guard
func isPlannableResource(r *plans.ResourceChange) bool {
switch r.Addr.Resource.Resource.Mode {
case addrs.ManagedResourceMode, addrs.DataResourceMode:
return true
}
return false
} Prevention
- 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.
When it happens
Trigger: 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.
Common situations: Same as 620: dev/internal builds routing unsupported modes into JSON plan serialization; cross-version plan consumption.
Related errors
- resource has an unsupported mode
- resource has an unsupported action reason
- resource has an unsupported mode
- A managed resource address is required. Importing into a…
- error reading output values
AI-assisted analysis of hashicorp/terraform@d32a084675 (2026-08-11).
Data as JSON: /api/errors/fbd77361dde21a2c.
Report an issue: GitHub.
Appendix: source
Thrown at internal/command/jsonplan/values.go:191
if r.Action == plans.Delete || r.Action == plans.Forget {
continue
}
resource := resource{
Address: r.Addr.String(),
Type: r.Addr.Resource.Resource.Type,
Name: r.Addr.Resource.Resource.Name,
ProviderName: r.ProviderAddr.Provider.String(),
Index: r.Addr.Resource.Key,
}
switch r.Addr.Resource.Resource.Mode {
case addrs.ManagedResourceMode:
resource.Mode = "managed"
case addrs.DataResourceMode:
resource.Mode = "data"
default:
return nil, fmt.Errorf("resource %s has an unsupported mode %s",
r.Addr.String(),
r.Addr.Resource.Resource.Mode.String(),
)
}
schema := schemas.ResourceTypeConfig(
r.ProviderAddr.Provider,
r.Addr.Resource.Resource.Mode,
resource.Type,
)
if schema.Body == nil {
return nil, fmt.Errorf("no schema found for %s", r.Addr.String())
}
resource.SchemaVersion = uint64(schema.Version)
changeV, err := r.Decode(schema)
if err != nil {
return nil, err
}View on GitHub (pinned to d32a084675)