hashicorp/terraform · warning
The pattern '*' cannot be used more than once.
Error message
The pattern '*' cannot be used more than once.
What it means
Returned during multi-state-to-TFC workspace renaming when the user-supplied pattern contains more than one '*' character. Exactly one '*' is allowed because it is substituted with a single workspace name; multiple wildcards would be ambiguous.
Source
Thrown at internal/command/meta_backend_migrate.go:978
// returning a generic '*' that means use the same workspace name during
// migration.
return "*", nil
}
pattern, err := m.UIInput().Input(context.Background(), &terraform.InputOpts{
Id: "backend-migrate-multistate-to-tfc-pattern",
Query: fmt.Sprintf("[reset][bold][yellow]%s[reset]", "How would you like to rename your workspaces?"),
Description: strings.TrimSpace(tfcInputBackendMigrateMultiToMultiPattern),
})
if err != nil {
return "", fmt.Errorf("Error asking for state migration action: %s", err)
}
if !strings.Contains(pattern, "*") {
return "", fmt.Errorf("The pattern must have an '*'")
}
if count := strings.Count(pattern, "*"); count > 1 {
return "", fmt.Errorf("The pattern '*' cannot be used more than once.")
}
return pattern, nil
}
const errMigrateLoadStates = `
Error inspecting states in the %q backend:
%s
Prior to changing backends, Terraform inspects the source and destination
states to determine what kind of migration steps need to be taken, if any.
Terraform failed to load the states. The data in both the source and the
destination remain unmodified. Please resolve the above error and try again.
`
const errMigrateSingleLoadDefault = `
Error loading state:
%[2]sView on GitHub (pinned to c9def3e214)
Solutions
- Re-enter a pattern with exactly one '*', e.g. 'prefix-*' or '*-prod'.
- If you need more complex naming, perform migrations one workspace at a time or rename workspaces in the destination manually.
- Avoid '**' and multiple '*' — only a single placeholder is supported.
Example fix
// before // pattern entered: '*-*' -> error (two '*') // after // pattern entered: 'migrated-*'
Defensive patterns
Strategy: validation
Validate before calling
// Ensure at most one '*'
if strings.Count(pattern, "*") > 1 {
return fmt.Errorf("pattern may contain at most one '*'")
} Type guard
func isValidRenamePattern(p string) bool {
return strings.Contains(p, "*") && strings.Count(p, "*") == 1
} Prevention
- Use exactly one '*' in the rename pattern.
- Avoid '**' glob-style patterns; they are not supported.
- For multiple distinct names, migrate workspaces individually instead.
- Validate patterns before submitting them programmatically.
When it happens
Trigger: promptMultiStateMigrationPattern: after confirming the pattern contains '*', `strings.Count(pattern, "*")` returns a value greater than 1. Examples: 'a-*-b-*', '**', '*-*' all fail.
Common situations: User treats '*' as a glob and types '**'; user wants two substitution points (unsupported); accidental double asterisk from copy-paste or shell globbing.
Related errors
- The pattern must have an '*'
- Please select 1 or 2 as part of this option.
- Error asking for new state name: %s
- Invalid value: %s
- default workspace not supported You can create a new workspa
AI-assisted analysis of hashicorp/terraform@c9def3e214 (2026-08-07).
Data as JSON: /api/errors/699e68f536fc0f3b.
Report an issue: GitHub.