{"record":{"id":"222477d2b19afd18","repo":"hashicorp/terraform","slug":"s-s-222477","errorCode":null,"errorMessage":"[%s] %s","messagePattern":"\\[%s\\] %s","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/configs/hcl2shim/paths.go","lineNumber":93,"sourceCode":"\treturn path\n}\n\n// requiresReplacePath takes a key from a flatmap along with the cty.Type\n// describing the structure, and returns the cty.Path that would be used to\n// reference the nested value in the data structure.\n// This is used specifically to record the RequiresReplace attributes from a\n// ResourceInstanceDiff.\nfunc requiresReplacePath(k string, ty cty.Type) (cty.Path, error) {\n\tif k == \"\" {\n\t\treturn nil, nil\n\t}\n\tif !ty.IsObjectType() {\n\t\tpanic(fmt.Sprintf(\"requires replace path on non-object type: %#v\", ty))\n\t}\n\n\tpath, err := pathFromFlatmapKeyObject(k, ty.AttributeTypes())\n\tif err != nil {\n\t\treturn path, fmt.Errorf(\"[%s] %s\", k, err)\n\t}\n\treturn path, nil\n}\n\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}}","sourceCodeStart":75,"sourceCodeEnd":111,"githubUrl":"https://github.com/hashicorp/terraform/blob/c9def3e214014c1188faabfc4a5bde5095139765/internal/configs/hcl2shim/paths.go#L75-L111","documentation":"Returned by requiresReplacePath (paths.go:93) as a wrapper around any error produced by pathFromFlatmapKeyObject while converting a flatmap key into a cty.Path for a resource attribute flagged RequiresReplace. The wrapper prepends the original flatmap key '[%s]' so the caller knows which attribute key triggered the inner failure (which will be one of attribute-not-found, invalid-step, unrecognized-type, or out-of-range).","triggerScenarios":"Terraform computes a resource instance diff where one or more attributes are marked as forcing replacement (RequiresNew). RequiresReplace then iterates those flatmap keys and calls requiresReplacePath; if any key cannot be mapped onto the resource's object type, the inner error is wrapped here.","commonSituations":"A diff contains a RequiresReplace flatmap key that does not correspond to any attribute in the current schema (schema drifted, or a computed/removed attribute got into the diff). Provider schema and state are out of sync. A planner emitted an unexpected key shape.","solutions":["Read the inner error (after the ']') — it is the root cause (e.g. 'attribute X not found'); fix that specific condition first.","Confirm the resource's current schema contains every attribute key mentioned in the RequiresReplace list.","If an attribute was renamed/removed, migrate state or re-apply to regenerate the diff under the new schema.","Pin provider versions so the planner and schema agree."],"exampleFix":"// before — diff marks RequiresReplace on key 'old_name.0.value',\n// but schema now calls it 'new_name'\n\n// after — migrate state / re-apply so the diff uses the current attribute name","handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"paths, err := hcl2shim.RequiresReplace(requiresReplaceAttrs, ty)\nif err != nil {\n    // the wrapped '[key] inner-error' tells you which diff key is stale;\n    // fall back to replacing the whole resource rather than failing the plan\n    log.Printf(\"[WARN] cannot map requires-replace attrs: %v; treating all as replace\", err)\n    return []cty.Path{{cty.GetAttrStep{Name: \"__all__\"}}}, nil\n}","preventionTips":["Keep the resource schema and the diff's RequiresReplace keys in sync (no removed/renamed attributes).","Pin provider versions through schema changes; migrate state first.","Treat the wrapped '[key]' prefix in the message as the diagnostic: investigate that specific attribute."],"tags":["hcl2shim","paths","requires-replace","diff","schema-drift"],"analyzedSha":"c9def3e214014c1188faabfc4a5bde5095139765","analyzedAt":"2026-08-07T15:39:49.278Z","schemaVersion":2},"datasetVersion":"2026-08-07T21:17:07.882Z"}