hashicorp/terraform · critical
resource has an unsupported mode
Error message
resource %s has an unsupported mode %s
What it means
Thrown by marshalResources when a configured resource's Mode is neither addrs.ManagedResourceMode nor addrs.DataResourceMode. The resource address and the unexpected mode string are included. This indicates an internal/state divergence: the configs layer should only ever produce managed or data resources.
Solutions
- Report as a Terraform bug with the config and version, since HCL authoring cannot produce other modes.
- Ensure you are running a released, mutually-consistent Terraform build (not a partial custom build).
- Remove recently added custom patches to addrs/configs and use official binaries.
Defensive patterns
Strategy: type-guard
Validate before calling
// Guard before marshaling: only marshal known modes.
func supportedMode(m addrs.ResourceMode) bool {
return m == addrs.ManagedResourceMode || m == addrs.DataResourceMode
} Type guard
func isValidResourceMode(m addrs.ResourceMode) bool {
return m == addrs.ManagedResourceMode || m == addrs.DataResourceMode
} Prevention
- Use official Terraform builds; do not mix addrs/configs versions.
- Treat this error as a bug — report it with the config.
- Avoid patching ResourceMode enums without updating marshalResources.
When it happens
Trigger: A resource in the loaded configuration carries a mode value outside the two valid cases. In practice unreachable through HCL authoring; would arise from a programmatic/buggy config load or an internal addrs package change introducing a new mode not handled here.
Common situations: Terraform internal bug; mismatched versions between addrs and configs packages; custom builds that extend ResourceMode without updating marshalResources.
Related errors
- found invalid type within path
- A managed resource address is required. Importing into a…
- can not read leafPassphraseBytes from
- Error initializing backend %T
- expected on 1 response value, got
AI-assisted analysis of hashicorp/terraform@d32a084675 (2026-08-11).
Data as JSON: /api/errors/feee96842477be5a.
Report an issue: GitHub.
Appendix: source
Thrown at internal/command/jsonconfig/config.go:488
func marshalResources(resources map[string]*configs.Resource, schemas *terraform.Schemas, moduleAddr string) ([]resource, error) {
var rs []resource
for _, v := range resources {
providerConfigKey := opaqueProviderKey(v.ProviderConfigAddr().StringCompact(), moduleAddr)
r := resource{
Address: v.Addr().String(),
Type: v.Type,
Name: v.Name,
ProviderConfigKey: providerConfigKey,
}
switch v.Mode {
case addrs.ManagedResourceMode:
r.Mode = "managed"
case addrs.DataResourceMode:
r.Mode = "data"
default:
return rs, fmt.Errorf("resource %s has an unsupported mode %s", r.Address, v.Mode.String())
}
cExp := marshalExpression(v.Count)
if !cExp.Empty() {
r.CountExpression = &cExp
} else {
fExp := marshalExpression(v.ForEach)
if !fExp.Empty() {
r.ForEachExpression = &fExp
}
}
schema := schemas.ResourceTypeConfig(
v.Provider,
v.Mode,
v.Type,
)
if schema.Body == nil {View on GitHub (pinned to d32a084675)