{"record":{"id":"766a5f5bd88f1f69","repo":"hashicorp/terraform","slug":"attribute-q-not-found","errorCode":null,"errorMessage":"attribute %q not found","messagePattern":"attribute %q not found","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/configs/hcl2shim/paths.go","lineNumber":115,"sourceCode":"\nfunc pathSplit(p string) (string, string) {\n\tparts := strings.SplitN(p, \".\", 2)\n\thead := parts[0]\n\trest := \"\"\n\tif len(parts) > 1 {\n\t\trest = parts[1]\n\t}\n\treturn head, rest\n}\n\nfunc pathFromFlatmapKeyObject(key string, atys map[string]cty.Type) (cty.Path, error) {\n\tk, rest := pathSplit(key)\n\n\tpath := cty.Path{cty.GetAttrStep{Name: k}}\n\n\tty, ok := atys[k]\n\tif !ok {\n\t\treturn path, fmt.Errorf(\"attribute %q not found\", k)\n\t}\n\n\tif rest == \"\" {\n\t\treturn path, nil\n\t}\n\n\tp, err := pathFromFlatmapKeyValue(rest, ty)\n\tif err != nil {\n\t\treturn path, err\n\t}\n\n\treturn append(path, p...), nil\n}\n\nfunc pathFromFlatmapKeyValue(key string, ty cty.Type) (cty.Path, error) {\n\tvar path cty.Path\n\tvar err error\n","sourceCodeStart":97,"sourceCodeEnd":133,"githubUrl":"https://github.com/hashicorp/terraform/blob/d32a084675427f5ac3f7d2868578ef8b2c1dc525/internal/configs/hcl2shim/paths.go#L97-L133","documentation":"Returned by pathFromFlatmapKeyObject when the leading path segment (the attribute name extracted by pathSplit) does not exist as a key in the object's attribute-types map. The decoder has built a GetAttrStep for it but cannot continue because the type of the (non-existent) attribute is unknown. This is the most common root cause surfaced through the [852] wrapper.","triggerScenarios":"Translating a flatmap key whose first dotted segment names an attribute that is not declared in the object type's AttributeTypes(). Triggered when RequiresReplace or a diff key references an attribute that the schema no longer (or never did) declare.","commonSituations":"Schema rename or removal of an attribute that remains referenced by RequiresReplace, a stored diff, or an old plan; merging diffs from different provider versions; custom providers that emit RequiresReplace keys without matching them to declared attributes.","solutions":["Match the attribute name in the error against the current schema; rename the reference or restore the attribute.","If the attribute was legitimately removed, drop it from RequiresReplace and recompute the plan.","Pin the provider version so the schema and the persisted diff/RequiresReplace list stay in sync.","Add a schema-state compatibility test that decodes a known RequiresReplace key set against the current schema."],"exampleFix":"// before: flatmap key 'legacy_field.nested' but schema has no 'legacy_field'\n// after: either rename to the current attribute, or remove the entry\n//   RequiresReplace: []cty.Path{{cty.GetAttrStep{Name: \"current_field\"}}}","handlingStrategy":"validation","validationCode":"func flatmapKeyRefersToDeclaredAttr(key string, atys map[string]cty.Type) bool {\n    head, _ := pathSplit(key)\n    _, ok := atys[head]\n    return ok\n}","typeGuard":"func flatmapKeyRefersToDeclaredAttr(key string, atys map[string]cty.Type) bool {\n    head, _ := pathSplit(key)\n    _, ok := atys[head]\n    return ok\n}","tryCatchPattern":null,"preventionTips":["When renaming or removing an attribute, update every RequiresReplace list that references it.","Pin provider version during refactors that rename schema attributes.","Cross-validate RequiresReplace against the schema in provider tests."],"tags":["flatmap","hcl2shim","paths","schema-mismatch","go"],"backgroundTag":null,"analyzedSha":"d32a084675427f5ac3f7d2868578ef8b2c1dc525","analyzedAt":"2026-08-11T18:43:52.779Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}