{"record":{"id":"ca4b649001d38c1b","repo":"hashicorp/terraform","slug":"s-s-name-defined-as-both-attribute-and-child-blo","errorCode":null,"errorMessage":"%s%s: name defined as both attribute and child block type","messagePattern":"(.+?)(.+?): name defined as both attribute and child block type","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/configs/configschema/internal_validate.go","lineNumber":56,"sourceCode":"\t\t\tmultiErr = errors.Join(multiErr, fmt.Errorf(\"%s%s: attribute schema is nil\", prefix, name))\n\t\t\tcontinue\n\t\t}\n\t\tmultiErr = errors.Join(multiErr, attrS.internalValidate(name, prefix))\n\n\t\t// all attributes within a computed block must also be computed\n\t\tif b.Computed && !attrS.Computed {\n\t\t\tmultiErr = errors.Join(multiErr, fmt.Errorf(\"%s%s: all attributes within computed blocks must also be computed\", prefix, name))\n\t\t}\n\t}\n\n\tfor name, blockS := range b.BlockTypes {\n\t\tif blockS == nil {\n\t\t\tmultiErr = errors.Join(multiErr, fmt.Errorf(\"%s%s: block schema is nil\", prefix, name))\n\t\t\tcontinue\n\t\t}\n\n\t\tif _, isAttr := b.Attributes[name]; isAttr {\n\t\t\tmultiErr = errors.Join(multiErr, fmt.Errorf(\"%s%s: name defined as both attribute and child block type\", prefix, name))\n\t\t} else if !validName.MatchString(name) {\n\t\t\tmultiErr = errors.Join(multiErr, fmt.Errorf(\"%s%s: name may contain only lowercase letters, digits and underscores\", prefix, name))\n\t\t}\n\t\tif !blockS.Deprecated && blockS.DeprecationMessage != \"\" {\n\t\t\tmultiErr = errors.Join(multiErr, fmt.Errorf(\"%s%s: DeprecationMessage must not be set when Deprecated is false\", prefix, name))\n\t\t}\n\n\t\tif blockS.MinItems < 0 || blockS.MaxItems < 0 {\n\t\t\tmultiErr = errors.Join(multiErr, fmt.Errorf(\"%s%s: MinItems and MaxItems must both be greater than zero\", prefix, name))\n\t\t}\n\n\t\t// any nested blocks within a computed block must also be computed\n\t\tif b.Computed && !blockS.Computed {\n\t\t\tmultiErr = errors.Join(multiErr, fmt.Errorf(\"%s%s: all nested blocks within computed blocks must also be computed\", prefix, name))\n\t\t}\n\n\t\tswitch blockS.Nesting {\n\t\tcase NestingSingle:","sourceCodeStart":38,"sourceCodeEnd":74,"githubUrl":"https://github.com/hashicorp/terraform/blob/c9def3e214014c1188faabfc4a5bde5095139765/internal/configs/configschema/internal_validate.go#L38-L74","documentation":"The same name is present in both b.Attributes and b.BlockTypes (checked at lines 55-56) - Terraform cannot decide whether that identifier is an attribute or a nested block, so it is rejected. Note this check runs before the name-format check (line 57) and is mutually exclusive with it via else-if.","triggerScenarios":"Defining `b.Attributes[\"foo\"]` and `b.BlockTypes[\"foo\"]` in the same Block, usually from merging two schema fragments or a copy-paste during an attribute->block conversion.","commonSituations":"Schema composition/inheritance, converting an attribute to a block without removing the old entry, generated schemas merging maps.","solutions":["Rename one of them so attribute and block-type names are disjoint.","Remove the obsolete entry (e.g. delete the attribute when it became a block)."],"exampleFix":"// before\nAttributes: map[string]*configschema.Attribute{ \"rule\": {Type: cty.String, Optional: true} }\nBlockTypes:  map[string]*configschema.NestedBlock{ \"rule\": {Nesting: configschema.NestingList} }\n\n// after\nAttributes: map[string]*configschema.Attribute{ \"rule\": {Type: cty.String, Optional: true} }\nBlockTypes:  map[string]*configschema.NestedBlock{ \"rule_block\": {Nesting: configschema.NestingList} }","handlingStrategy":"validation","validationCode":"for name := range block.BlockTypes {\n    if _, dup := block.Attributes[name]; dup {\n        return fmt.Errorf(\"name %q is both attribute and block\", name)\n    }\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["When composing schemas, de-duplicate names between Attributes and BlockTypes.","Rename during attribute->block conversions rather than leaving both."],"tags":["configschema","provider-sdk","naming","validation"],"analyzedSha":"c9def3e214014c1188faabfc4a5bde5095139765","analyzedAt":"2026-08-07T15:39:49.278Z","schemaVersion":2},"datasetVersion":"2026-08-07T21:17:07.882Z"}