hashicorp/terraform · error
empty state name
Error message
empty state name
What it means
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.
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.
Example fix
// before
Block: configschema.Block{
Computed: true,
BlockTypes: map[string]*configschema.NestedBlock{
"child": { Nesting: configschema.NestingList }, // Computed missing
},
},
// after
Block: configschema.Block{
Computed: true,
BlockTypes: map[string]*configschema.NestedBlock{
"child": { Nesting: configschema.NestingList, Block: configschema.Block{Computed: true} },
},
}, Defensive patterns
Strategy: validation
Validate before calling
// Propagate Computed to all nested block types when the parent is Computed.
func cascadeComputed(b *configschema.Block) {
if b == nil || !b.Computed { return }
for _, nb := range b.BlockTypes {
nb.Computed = true
cascadeComputed(&nb.Block)
}
} Type guard
// allNestedComputed reports whether every child block type is computed.
func allNestedComputed(b *configschema.Block) bool {
if b == nil { return true }
for _, nb := range b.BlockTypes {
if !nb.Computed { return false }
}
return true
} Prevention
- 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.
When it happens
Trigger: 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`.
Common situations: 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.
Related errors
- invalid lock id
- invalid md5
- invalid md5
- lost consul lock, cannot re-lock
- the state is already locked by another terraform client
AI-assisted analysis of hashicorp/terraform@d32a084675 (2026-08-11).
Data as JSON: /api/errors/be354295f38283c2.
Report an issue: GitHub.
Appendix: source
Thrown at internal/backend/local/backend.go:244
sort.Strings(listed)
envs = append(envs, listed...)
return envs, diags
}
// DeleteWorkspace removes a workspace.
//
// The "default" workspace cannot be removed.
func (b *Local) DeleteWorkspace(name string, force bool) tfdiags.Diagnostics {
var diags tfdiags.Diagnostics
// If we have a backend handling state, defer to that.
if b.Backend != nil {
return b.Backend.DeleteWorkspace(name, force)
}
if name == "" {
return diags.Append(errors.New("empty state name"))
}
if name == backend.DefaultStateName {
return diags.Append(errors.New("cannot delete default state"))
}
delete(b.states, name)
err := os.RemoveAll(filepath.Join(b.stateWorkspaceDir(), name))
if err != nil {
return diags.Append(fmt.Errorf("error deleting workspace %s: %w", name, err))
}
return diags
}
func (b *Local) StateMgr(name string) (statemgr.Full, tfdiags.Diagnostics) {
var diags tfdiags.Diagnostics
View on GitHub (pinned to d32a084675)