hashicorp/terraform · error
workspaces not supported
Error message
workspaces not supported
What it means
A NestedBlock has a negative MinItems or MaxItems. Counts represent block occurrence limits and cannot be negative. Note the message says 'greater than zero' but the code only rejects values < 0; zero (meaning unset/unbounded) is allowed.
Solutions
- Clamp MinItems and MaxItems to >= 0; use 0 to mean 'no limit'.
- If you intended 'at least one', set MinItems: 1 (only valid in NestingList/NestingSet/NestingSingle).
- Re-run InternalValidate in the provider test suite to confirm.
Example fix
// before MinItems: required - 2, // can go negative MaxItems: -1, // after MinItems: max(0, required-2), MaxItems: 0, // 0 = unbounded
Defensive patterns
Strategy: validation
Validate before calling
// Reject negative counts before constructing the schema.
func validCounts(min, max int) bool {
return min >= 0 && max >= 0
} Type guard
func nonNegativeCounts(min, max int) bool { return min >= 0 && max >= 0 } Prevention
- Treat MinItems/MaxItems as unsigned counts; never use -1 as a sentinel.
- Compute counts with max(0, expr) to avoid underflow.
- Use 0 for MaxItems to mean 'unbounded'.
When it happens
Trigger: Setting MinItems: -1 or MaxItems: -1 on a NestedBlock, often from an arithmetic expression or a default constant that underflows. The guard at internal_validate.go:64 is `blockS.MinItems < 0 || blockS.MaxItems < 0`.
Common situations: Computing MinItems/MaxItems from a subtraction that goes negative; porting a schema where -1 was a sentinel for 'unlimited' in another system; typos in generated schema code.
Related errors
- cannot delete default state
- consul lock was lost
- failed to append certs
- missing state name
- execution halted
AI-assisted analysis of hashicorp/terraform@d32a084675 (2026-08-11).
Data as JSON: /api/errors/36a249e32c021fc5.
Report an issue: GitHub.
Appendix: source
Thrown at internal/backend/backend.go:37
// DefaultStateName is the name of the default, initial state that every
// backend must have. This state cannot be deleted.
const DefaultStateName = "default"
var (
// ErrDefaultWorkspaceNotSupported is returned when an operation does not
// support using the default workspace, but requires a named workspace to
// be selected.
ErrDefaultWorkspaceNotSupported = errors.New("default workspace not supported\n" +
"You can create a new workspace with the \"workspace new\" command.")
// ErrWorkspacesNotSupported is an error returned when a caller attempts
// to perform an operation on a workspace other than "default" for a
// backend that doesn't support multiple workspaces.
//
// The caller can detect this to do special fallback behavior or produce
// a specific, helpful error message.
ErrWorkspacesNotSupported = errors.New("workspaces not supported")
)
// InitFn is used to initialize a new backend.
type InitFn func() Backend
// Backend is the minimal interface that must be implemented to enable Terraform.
type Backend interface {
// ConfigSchema returns a description of the expected configuration
// structure for the receiving backend.
//
// This method does not have any side-effects for the backend and can
// be safely used before configuring.
ConfigSchema() *configschema.Block
// PrepareConfig checks the validity of the values in the given
// configuration, and inserts any missing defaults, assuming that its
// structure has already been validated per the schema returned by
// ConfigSchema.View on GitHub (pinned to d32a084675)