{"record":{"id":"c10018c3f8fb558e","repo":"hashicorp/terraform","slug":"s-s-name-may-contain-only-lowercase-letters-dig","errorCode":null,"errorMessage":"%s%s: name may contain only lowercase letters, digits and underscores","messagePattern":"(.+?)(.+?): name may contain only lowercase letters, digits and underscores","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/configs/configschema/internal_validate.go","lineNumber":58,"sourceCode":"\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:\n\t\t\tswitch {\n\t\t\tcase blockS.MinItems != blockS.MaxItems:","sourceCodeStart":40,"sourceCodeEnd":76,"githubUrl":"https://github.com/hashicorp/terraform/blob/c9def3e214014c1188faabfc4a5bde5095139765/internal/configs/configschema/internal_validate.go#L40-L76","documentation":"A nested-block type name fails the validName regex `^[a-z0-9_]+$` (checked at line 57): it contains uppercase letters, hyphens, dots, or other characters. Terraform identifiers for block types must be lowercase snake_case. The identical check is commented out for attributes (see the FIXME at lines 141-145) but IS enforced for block types.","triggerScenarios":"Naming a nested block `myBlock`, `my-block`, or `MyBlock` in a schema literal; generated schemas emitting camelCase names from an API spec.","commonSituations":"Copying JSON/YAML field names into Go schema literals, SDK generation from a spec using camelCase, mixing naming conventions.","solutions":["Rename the block type to lowercase snake_case: `myBlock` -> `my_block`.","If generating schemas, add a normalization pass that lowercases and replaces separators with underscores."],"exampleFix":"// before\nBlockTypes: map[string]*configschema.NestedBlock{ \"subnetConfig\": {Nesting: configschema.NestingList} }\n\n// after\nBlockTypes: map[string]*configschema.NestedBlock{ \"subnet_config\": {Nesting: configschema.NestingList} }","handlingStrategy":"validation","validationCode":"var validName = regexp.MustCompile(`^[a-z0-9_]+$`)\nfor name := range block.BlockTypes {\n    if !validName.MatchString(name) { return fmt.Errorf(\"invalid block name %q\", name) }\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Use lowercase snake_case for all block type names.","Gate generated schemas with a normalization pass (lowercase + replace separators with _)."],"tags":["configschema","provider-sdk","naming","validation"],"analyzedSha":"c9def3e214014c1188faabfc4a5bde5095139765","analyzedAt":"2026-08-07T15:39:49.278Z","schemaVersion":2},"datasetVersion":"2026-08-07T21:17:07.882Z"}