{"record":{"id":"76dd6b11beb13f5a","repo":"hashicorp/terraform","slug":"s-s-block-schema-is-nil","errorCode":null,"errorMessage":"%s%s: block schema is nil","messagePattern":"(.+?)(.+?): block schema is nil","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/configs/configschema/internal_validate.go","lineNumber":51,"sourceCode":"\t\tmultiErr = errors.Join(multiErr, fmt.Errorf(\"top-level block: DeprecationMessage must not be set when Deprecated is false\"))\n\t}\n\n\tfor name, attrS := range b.Attributes {\n\t\tif attrS == nil {\n\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 {","sourceCodeStart":33,"sourceCodeEnd":69,"githubUrl":"https://github.com/hashicorp/terraform/blob/c9def3e214014c1188faabfc4a5bde5095139765/internal/configs/configschema/internal_validate.go#L33-L69","documentation":"A nil entry exists in a Block's BlockTypes map (b.BlockTypes[name] == nil, checked at line 50). Analogous to 809 but for nested blocks; the validator skips recursion (`continue`) and records the error. Means a nested-block placeholder was left nil.","triggerScenarios":"Building BlockTypes with `\"settings\": nil` or assigning a nil *NestedBlock from a helper that didn't populate it.","commonSituations":"Generated schemas, conditional nested-block construction returning nil, refactor leftovers.","solutions":["Provide a full *NestedBlock (with a non-nil inner Block and a valid Nesting mode) for every key.","Omit the key if the nested block shouldn't exist."],"exampleFix":"// before\nBlockTypes: map[string]*configschema.NestedBlock{\n    \"settings\": nil,\n}\n\n// after\nBlockTypes: map[string]*configschema.NestedBlock{\n    \"settings\": {Nesting: configschema.NestingSingle, Block: configschema.Block{Attributes: map[string]*configschema.Attribute{\"x\": {Type: cty.String, Optional: true}}}},\n}","handlingStrategy":"validation","validationCode":"for k, nb := range block.BlockTypes {\n    if nb == nil { return fmt.Errorf(\"nested block %q is nil\", k) }\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Never store nil in BlockTypes; omit the entry instead.","Validate nested-block construction returns a populated *NestedBlock before insertion."],"tags":["configschema","provider-sdk","nil-pointer","validation"],"analyzedSha":"c9def3e214014c1188faabfc4a5bde5095139765","analyzedAt":"2026-08-07T15:39:49.278Z","schemaVersion":2},"datasetVersion":"2026-08-07T21:17:07.882Z"}