hashicorp/terraform · error
unrecognized type: %s
Error message
unrecognized type: %s
What it means
Returned by pathFromFlatmapKeyValue (paths.go:148) in the default branch of its type switch — the cty.Type matched none of primitive, object, tuple, map, list, or set. This indicates an unrecognized or unsupported type in the flatmap-key-to-path conversion path, such as a capsule type or a dynamic pseudo-type that was not resolved.
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 c9def3e214)
Solutions
- Print ty.FriendlyName() (shown in the message) and confirm the type is one flatmap paths can handle.
- Resolve any DynamicPseudoType to a concrete type before it reaches the path shim.
- Replace unsupported capsule types in schema attributes with standard cty kinds, or handle them in a dedicated code path.
- Validate provider schemas with InternalValidate in tests to catch exotic types early.
Example fix
// before — attr Type set to a custom capsule type
attr := &configschema.Attribute{Type: myCapsule}
// after — use a standard cty kind
attr := &configschema.Attribute{Type: cty.Map(cty.String)} Defensive patterns
Strategy: validation
Validate before calling
// Only the 6 standard kinds are path-navigable
func isPathNavigable(ty cty.Type) bool {
return ty.IsPrimitiveType() || ty.IsObjectType() || ty.IsTupleType() ||
ty.IsMapType() || ty.IsListType() || ty.IsSetType()
} Type guard
func isPathNavigable(ty cty.Type) bool {
return ty.IsPrimitiveType() || ty.IsObjectType() || ty.IsTupleType() ||
ty.IsMapType() || ty.IsListType() || ty.IsSetType()
} Prevention
- Do not put cty capsule types or unresolved DynamicPseudoType into schema attributes that reach the path shim.
- Resolve dynamic types to concrete types before decoding/navigating.
- Validate schemas with InternalValidate to reject exotic types early.
When it happens
Trigger: Calling requiresReplacePath / pathFromFlatmapKeyValue with a cty.Type that is not one of the six standard structural/primitive kinds. Reached when a schema attribute's type is a capsule or unresolved dynamic reaching the path-shim layer.
Common situations: Custom cty capsule types leaking into schema attributes. cty.DynamicPseudoType used where a concrete type was expected. Internally inconsistent type descriptors from a buggy provider schema.
Related errors
- Failed to marshal index step key %#v: %s
- cannot decode %s from flatmap
- [%s] %s
- attribute %q not found
- invalid step %q with type %#v
AI-assisted analysis of hashicorp/terraform@c9def3e214 (2026-08-07).
Data as JSON: /api/errors/edc3daffc14dd628.
Report an issue: GitHub.