{"record":{"id":"ada0526df9492848","repo":"hashicorp/terraform","slug":"s-s-all-nested-blocks-within-computed-blocks-mus","errorCode":null,"errorMessage":"%s%s: all nested blocks within computed blocks must also be computed","messagePattern":"(.+?)(.+?): all nested blocks within computed blocks must also be computed","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/configs/configschema/internal_validate.go","lineNumber":70,"sourceCode":"\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:\n\t\t\t\tmultiErr = errors.Join(multiErr, fmt.Errorf(\"%s%s: MinItems and MaxItems must match in NestingSingle mode\", prefix, name))\n\t\t\tcase blockS.MinItems < 0 || blockS.MinItems > 1:\n\t\t\t\tmultiErr = errors.Join(multiErr, fmt.Errorf(\"%s%s: MinItems and MaxItems must be set to either 0 or 1 in NestingSingle mode\", prefix, name))\n\t\t\t}\n\t\tcase NestingGroup:\n\t\t\tif blockS.MinItems != 0 || blockS.MaxItems != 0 {\n\t\t\t\tmultiErr = errors.Join(multiErr, fmt.Errorf(\"%s%s: MinItems and MaxItems cannot be used in NestingGroup mode\", prefix, name))\n\t\t\t}\n\t\t\tif blockS.Computed {\n\t\t\t\tmultiErr = errors.Join(multiErr, fmt.Errorf(\"%s%s: NestingGroup blocks cannot be computed\", prefix, name))\n\t\t\t}\n\t\tcase NestingList, NestingSet:","sourceCodeStart":52,"sourceCodeEnd":88,"githubUrl":"https://github.com/hashicorp/terraform/blob/c9def3e214014c1188faabfc4a5bde5095139765/internal/configs/configschema/internal_validate.go#L52-L88","documentation":"When a parent Block is Computed, every nested child block (BlockTypes entry) must also be Computed (checked at lines 69-70) - the mirror of rule 810 for nested blocks. A computed (provider-supplied) block cannot embed user-editable sub-blocks.","triggerScenarios":"Marking an outer block Computed=true while a nested block inside it stays Computed=false.","commonSituations":"Migrating a config object to a computed output, framework schema rewrites where inner blocks weren't updated.","solutions":["Set Computed=true on every nested block within a computed block.","If the nested block must be user-editable, the parent cannot be Computed."],"exampleFix":"// before\n&configschema.Block{\n    Computed: true,\n    BlockTypes: map[string]*configschema.NestedBlock{\n        \"spec\": {Nesting: configschema.NestingSingle, Block: configschema.Block{Computed: false}},\n    },\n}\n\n// after\n&configschema.Block{\n    Computed: true,\n    BlockTypes: map[string]*configschema.NestedBlock{\n        \"spec\": {Nesting: configschema.NestingSingle, Block: configschema.Block{Computed: true}},\n    },\n}","handlingStrategy":"validation","validationCode":"if block.Computed {\n    for n, nb := range block.BlockTypes {\n        if nb != nil && !nb.Computed { return fmt.Errorf(\"%s: nested block must be computed\", n) }\n    }\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["When marking a block Computed, recursively set Computed on all nested blocks and attributes.","Keep user-settable nested blocks out of computed parent blocks."],"tags":["configschema","provider-sdk","computed","validation"],"analyzedSha":"c9def3e214014c1188faabfc4a5bde5095139765","analyzedAt":"2026-08-07T15:39:49.278Z","schemaVersion":2},"datasetVersion":"2026-08-07T20:17:04.800Z"}