{"record":{"id":"222477d2b19afd18","repo":"hashicorp/terraform","slug":"s-s-222477","errorCode":null,"errorMessage":"[%s] %s","messagePattern":"\\[%s\\] %s","errorType":"validation","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/d32a084675427f5ac3f7d2868578ef8b2c1dc525/internal/configs/hcl2shim/paths.go#L75-L111","documentation":"Wrapper error produced by requiresReplacePath when translating a flatmap RequiresReplace key into a cty.Path fails. The original underlying error (from pathFromFlatmapKeyObject and friends) is preserved and shown after the flatmap key, so callers can identify both which attribute path was requested and why it could not be parsed.","triggerScenarios":"Calling requiresReplacePath(k, ty) where k is a flatmap-style key for a RequiresReplace attribute and ty is the resource's object type. Failure means the key does not correspond to a navigable attribute path inside ty (e.g. it references an attribute that does not exist, or contains a malformed index segment).","commonSituations":"A provider's schema lists RequiresReplace on an attribute name that has since been renamed/removed; state or schema migration left stale RequiresReplace entries; a custom diff producer emits a flatmap key with a typo or wrong separator.","solutions":["Read the wrapped error after the colon — it identifies the specific parsing failure (attribute not found, index out of range, etc.) and is the real cause.","Cross-reference the flatmap key against the current schema attribute names; rename or remove stale RequiresReplace entries.","Regenerate the diff with the current provider version so RequiresReplace reflects the live schema.","If the underlying error is 'attribute not found' (see [853]), the fix is to update the schema's RequiresReplace list."],"exampleFix":"// before: schema lists RequiresReplace for a renamed attribute\n//   RequiresReplace: []string{\"legacy_name\"}\n//\n// after:\n//   RequiresReplace: []string{\"new_name\"}","handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"path, err := requiresReplacePath(k, ty)\nif err != nil {\n    // err already includes the flatmap key prefix '[<k>]'; surface it as a\n    // schema/diff mismatch for the user, and skip this RequiresReplace entry.\n    log.Printf(\"[WARN] ignoring malformed RequiresReplace key %q: %v\", k, err)\n    continue\n}","preventionTips":["Keep RequiresReplace entries synchronized with the current schema attribute names.","Recompute diffs/RequiresReplace after schema changes rather than reusing cached values.","Add tests that decode every known RequiresReplace key against the live schema."],"tags":["flatmap","hcl2shim","paths","requires-replace","go"],"backgroundTag":null,"analyzedSha":"d32a084675427f5ac3f7d2868578ef8b2c1dc525","analyzedAt":"2026-08-11T18:43:52.779Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}