{"record":{"id":"be354295f38283c2","repo":"hashicorp/terraform","slug":"empty-state-name","errorCode":null,"errorMessage":"empty state name","messagePattern":"empty state name","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/backend/local/backend.go","lineNumber":244,"sourceCode":"\tsort.Strings(listed)\n\tenvs = append(envs, listed...)\n\n\treturn envs, diags\n}\n\n// DeleteWorkspace removes a workspace.\n//\n// The \"default\" workspace cannot be removed.\nfunc (b *Local) DeleteWorkspace(name string, force bool) tfdiags.Diagnostics {\n\tvar diags tfdiags.Diagnostics\n\n\t// If we have a backend handling state, defer to that.\n\tif b.Backend != nil {\n\t\treturn b.Backend.DeleteWorkspace(name, force)\n\t}\n\n\tif name == \"\" {\n\t\treturn diags.Append(errors.New(\"empty state name\"))\n\t}\n\n\tif name == backend.DefaultStateName {\n\t\treturn diags.Append(errors.New(\"cannot delete default state\"))\n\t}\n\n\tdelete(b.states, name)\n\terr := os.RemoveAll(filepath.Join(b.stateWorkspaceDir(), name))\n\tif err != nil {\n\t\treturn diags.Append(fmt.Errorf(\"error deleting workspace %s: %w\", name, err))\n\t}\n\n\treturn diags\n}\n\nfunc (b *Local) StateMgr(name string) (statemgr.Full, tfdiags.Diagnostics) {\n\tvar diags tfdiags.Diagnostics\n","sourceCodeStart":226,"sourceCodeEnd":262,"githubUrl":"https://github.com/hashicorp/terraform/blob/d32a084675427f5ac3f7d2868578ef8b2c1dc525/internal/backend/local/backend.go#L226-L262","documentation":"A parent block is marked Computed but a nested child block type within it is not Computed. Terraform requires that once a block is provider-computed, every nested block inside it must also be computed, so the whole subtree is provider-managed and no user-configured children leak in.","triggerScenarios":"Outer Block has Computed: true and a BlockTypes entry whose NestedBlock.Computed is false. The guard at internal_validate.go:69 is `b.Computed && !blockS.Computed`.","commonSituations":"Converting a user-configurable block into a computed one and forgetting to cascade Computed down to its child block types; mixing a computed datasource block with a user-settable child block.","solutions":["Set Computed: true on every nested block type inside the computed parent block.","If the child genuinely must be user-configurable, set the parent block's Computed: false.","Validate the whole subtree recursively with InternalValidate in a provider unit test."],"exampleFix":"// before\nBlock: configschema.Block{\n  Computed: true,\n  BlockTypes: map[string]*configschema.NestedBlock{\n    \"child\": { Nesting: configschema.NestingList }, // Computed missing\n  },\n},\n// after\nBlock: configschema.Block{\n  Computed: true,\n  BlockTypes: map[string]*configschema.NestedBlock{\n    \"child\": { Nesting: configschema.NestingList, Block: configschema.Block{Computed: true} },\n  },\n},","handlingStrategy":"validation","validationCode":"// Propagate Computed to all nested block types when the parent is Computed.\nfunc cascadeComputed(b *configschema.Block) {\n    if b == nil || !b.Computed { return }\n    for _, nb := range b.BlockTypes {\n        nb.Computed = true\n        cascadeComputed(&nb.Block)\n    }\n}","typeGuard":"// allNestedComputed reports whether every child block type is computed.\nfunc allNestedComputed(b *configschema.Block) bool {\n    if b == nil { return true }\n    for _, nb := range b.BlockTypes {\n        if !nb.Computed { return false }\n    }\n    return true\n}","tryCatchPattern":null,"preventionTips":["When marking a block Computed, recursively set Computed on all child block types.","Write a schema-builder helper that enforces the cascade invariant.","Test computed blocks with InternalValidate in CI."],"tags":["schema-validation","configschema","computed","nested-block","provider-schema"],"backgroundTag":null,"analyzedSha":"d32a084675427f5ac3f7d2868578ef8b2c1dc525","analyzedAt":"2026-08-11T18:43:52.779Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}