{"record":{"id":"766a5f5bd88f1f69","repo":"hashicorp/terraform","slug":"attribute-q-not-found","errorCode":null,"errorMessage":"attribute %q not found","messagePattern":"attribute %q not found","errorType":"exception","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/c9def3e214014c1188faabfc4a5bde5095139765/internal/configs/hcl2shim/paths.go#L97-L133","documentation":"Returned by pathFromFlatmapKeyObject (paths.go:115) when the first dot-separated segment of a flatmap key does not match any attribute name in the object's attribute-types map. This means the flatmap key references an attribute that the schema does not declare — a structural mismatch between the key space and the type being decoded.","triggerScenarios":"Converting a flatmap key (e.g. from a RequiresReplace diff or a diff path) into a cty.Path, where the leading segment is not present in ty.AttributeTypes(). The lookup `ty, ok := atys[k]` returns ok==false.","commonSituations":"Schema removed or renamed an attribute but state/diff still references the old name. A provider version change altered attribute names. Manually constructed flatmap keys with typos. Cross-provider state confusion.","solutions":["Look at the attribute name in the message; verify it exists in the current resource schema (it likely was renamed or removed).","Perform a state migration to rename the attribute, or re-import the resource.","Pin the provider version whose schema contains the attribute if a recent upgrade removed it.","Audit the diff/RequiresReplace source to ensure only current-schema attribute keys are emitted."],"exampleFix":"// before — key 'instnce_type' (typo) not in schema {'instance_type': ...}\n\n// after — correct the flatmap key / state attribute name to 'instance_type'","handlingStrategy":"validation","validationCode":"// Confirm every leading segment of a flatmap key exists in the schema\nfunc keysExistInSchema(keys []string, atys map[string]cty.Type) []string {\n    var missing []string\n    for _, k := range keys {\n        head, _, _ := strings.Cut(k, \".\")\n        if _, ok := atys[head]; !ok {\n            missing = append(missing, head)\n        }\n    }\n    return missing\n}","typeGuard":"func attributeExists(name string, atys map[string]cty.Type) bool {\n    _, ok := atys[name]\n    return ok\n}","tryCatchPattern":null,"preventionTips":["After renaming/removing a schema attribute, migrate state so old keys disappear.","Validate diff/RequiresReplace keys against the current schema before consumption.","Pin provider versions so state keys and schema stay aligned."],"tags":["hcl2shim","paths","schema-drift","attribute-not-found"],"analyzedSha":"c9def3e214014c1188faabfc4a5bde5095139765","analyzedAt":"2026-08-07T15:39:49.278Z","schemaVersion":2},"datasetVersion":"2026-08-07T21:17:07.882Z"}