{"record":{"id":"d9117b5c8059f4b4","repo":"hashicorp/terraform","slug":"s-s-deprecationmessage-must-not-be-set-when-depr","errorCode":null,"errorMessage":"%s%s: DeprecationMessage must not be set when Deprecated is false","messagePattern":"(.+?)(.+?): DeprecationMessage must not be set when Deprecated is false","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/configs/configschema/internal_validate.go","lineNumber":61,"sourceCode":"\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:\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))","sourceCodeStart":43,"sourceCodeEnd":79,"githubUrl":"https://github.com/hashicorp/terraform/blob/c9def3e214014c1188faabfc4a5bde5095139765/internal/configs/configschema/internal_validate.go#L43-L79","documentation":"For a child NestedBlock, DeprecationMessage is non-empty while Deprecated is false (checked at lines 60-61) - the same invariant as 808 but at the per-nested-block level (it runs in the BlockTypes loop, not the top-level guard). The deprecation message is only meaningful when the block is actually marked deprecated.","triggerScenarios":"Setting nb.DeprecationMessage on a nested block without nb.Deprecated = true.","commonSituations":"Incremental deprecation edits, generated schemas, copy-paste missing the flag.","solutions":["Set Deprecated = true on the NestedBlock alongside DeprecationMessage.","Or remove the DeprecationMessage if the block isn't deprecated."],"exampleFix":"// before\n\"settings\": {Nesting: configschema.NestingSingle, Block: configschema.Block{DeprecationMessage: \"use settings_v2\"}}\n\n// after\n\"settings\": {Nesting: configschema.NestingSingle, Block: configschema.Block{Deprecated: true, DeprecationMessage: \"use settings_v2\"}}","handlingStrategy":"validation","validationCode":"for n, nb := range block.BlockTypes {\n    if nb != nil && !nb.Deprecated && nb.DeprecationMessage != \"\" {\n        return fmt.Errorf(\"%s: DeprecationMessage set without Deprecated\", n)\n    }\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Always pair DeprecationMessage with Deprecated = true on nested blocks.","Reuse a shared deprecation helper so the invariant holds everywhere."],"tags":["configschema","provider-sdk","deprecation","validation"],"analyzedSha":"c9def3e214014c1188faabfc4a5bde5095139765","analyzedAt":"2026-08-07T15:39:49.278Z","schemaVersion":2},"datasetVersion":"2026-08-07T21:17:07.882Z"}