hashicorp/terraform · error
missing state name
Error message
missing state name
What it means
In NestingMap mode both MinItems and MaxItems must be 0. Map nesting keys blocks by label and does not use occurrence counts; setting either is a schema error. This mirrors the NestingGroup restriction.
Solutions
- Set both MinItems: 0 and MaxItems: 0 on the NestingMap block.
- If occurrence limits are required, use NestingList or NestingSet.
Example fix
// before
"labels": { Nesting: configschema.NestingMap, MinItems: 1, MaxItems: 5 },
// after
"labels": { Nesting: configschema.NestingMap, MinItems: 0, MaxItems: 0 }, Defensive patterns
Strategy: validation
Validate before calling
// NestingMap must keep MinItems and MaxItems at 0.
func validMapCounts(nb *configschema.NestedBlock) bool {
return nb.Nesting != configschema.NestingMap || (nb.MinItems == 0 && nb.MaxItems == 0)
} Type guard
func mapCountsZero(min, max int) bool { return min == 0 && max == 0 } Prevention
- NestingMap keys blocks by label; counts are not used.
- When converting from NestingList, clear MinItems/MaxItems.
- Use a per-mode schema builder that sets the right defaults.
When it happens
Trigger: NestingMap with MinItems or MaxItems != 0. Guard at internal_validate.go:111 is `blockS.MinItems != 0 || blockS.MaxItems != 0`.
Common situations: Switching from NestingList to NestingMap without clearing the count fields; assuming a map needs a minimum number of entries.
Related errors
- cannot delete default state
- consul lock was lost
- failed to append certs
- the state is already locked by another terraform client
- workspaces not supported
AI-assisted analysis of hashicorp/terraform@d32a084675 (2026-08-11).
Data as JSON: /api/errors/097493ea3be72230.
Report an issue: GitHub.
Appendix: source
Thrown at internal/backend/remote-state/kubernetes/backend_state.go:156
if err := stateMgr.PersistState(nil); err != nil {
unlockErr := unlock(err)
return nil, diags.Append(unlockErr)
}
// Unlock, the state should now be initialized
if err := unlock(nil); err != nil {
return nil, diags.Append(err)
}
}
return stateMgr, diags
}
// get a remote client configured for this state
func (b *Backend) remoteClient(name string) (*RemoteClient, error) {
if name == "" {
return nil, errors.New("missing state name")
}
secretClient, err := b.KubernetesSecretClient()
if err != nil {
return nil, err
}
leaseClient, err := b.KubernetesLeaseClient()
if err != nil {
return nil, err
}
client := &RemoteClient{
kubernetesSecretClient: secretClient,
kubernetesLeaseClient: leaseClient,
namespace: b.namespace,
labels: b.labels,
nameSuffix: b.nameSuffix,View on GitHub (pinned to d32a084675)