hashicorp/terraform · error
unrecognized type
Error message
unrecognized type: %s
What it means
Returned by pathFromFlatmapKeyValue when the current type does not match any handled branch (primitive, object, tuple, map, list, set) — i.e. the switch reaches its default. This typically means the type is cty.DynamicPseudoType or a capsule type, neither of which can be navigated by flatmap key segments.
Solutions
- Inspect the FriendlyName() in the error to identify the offending type.
- If the type is dynamic, replace it with a concrete type so the path can be navigated, or remove the attribute from RequiresReplace.
- If a capsule type is involved, encode the value as a concrete primitive (e.g. JSON string) instead.
- Regenerate the diff/RequiresReplace list against a concrete-typed schema.
Example fix
// before: attribute typed cty.DynamicPseudoType referenced in RequiresReplace // after: attribute typed cty.String (concrete) so the path is navigable
Defensive patterns
Strategy: type-guard
Validate before calling
func typeIsNavigable(ty cty.Type) bool {
return ty.IsPrimitiveType() || ty.IsObjectType() || ty.IsTupleType() ||
ty.IsMapType() || ty.IsListType() || ty.IsSetType()
} Type guard
func typeIsNavigable(ty cty.Type) bool {
if ty == cty.DynamicPseudoType { return false }
return ty.IsPrimitiveType() || ty.IsObjectType() || ty.IsTupleType() ||
ty.IsMapType() || ty.IsListType() || ty.IsSetType()
} Prevention
- Avoid cty.DynamicPseudoType in any attribute reachable from a flatmap path translation.
- Encode opaque payloads as JSON strings rather than dynamic types.
- Recompute RequiresReplace against a concrete-typed schema.
When it happens
Trigger: Translating a flatmap key against a schema position whose cty type is dynamic or otherwise non-navigable. Reached via requiresReplacePath and the pathFromFlatmapKey* family when descending through a type that has no flatmap representation.
Common situations: Schema attribute typed as cty.DynamicPseudoType appearing inside a RequiresReplace key; legacy state with dynamic-typed slots; custom providers using capsule types that the shim does not understand.
Related errors
AI-assisted analysis of hashicorp/terraform@d32a084675 (2026-08-11).
Data as JSON: /api/errors/edc3daffc14dd628.
Report an issue: GitHub.
Appendix: source
Thrown at internal/configs/hcl2shim/paths.go:148
func pathFromFlatmapKeyValue(key string, ty cty.Type) (cty.Path, error) {
var path cty.Path
var err error
switch {
case ty.IsPrimitiveType():
err = fmt.Errorf("invalid step %q with type %#v", key, ty)
case ty.IsObjectType():
path, err = pathFromFlatmapKeyObject(key, ty.AttributeTypes())
case ty.IsTupleType():
path, err = pathFromFlatmapKeyTuple(key, ty.TupleElementTypes())
case ty.IsMapType():
path, err = pathFromFlatmapKeyMap(key, ty)
case ty.IsListType():
path, err = pathFromFlatmapKeyList(key, ty)
case ty.IsSetType():
path, err = pathFromFlatmapKeySet(key, ty)
default:
err = fmt.Errorf("unrecognized type: %s", ty.FriendlyName())
}
if err != nil {
return path, err
}
return path, nil
}
func pathFromFlatmapKeyTuple(key string, etys []cty.Type) (cty.Path, error) {
var path cty.Path
var err error
k, rest := pathSplit(key)
// we don't need to convert the index keys to paths
if k == "#" {
return path, nilView on GitHub (pinned to d32a084675)