hashicorp/terraform · warning
Please select 1 or 2 as part of this option.
Error message
Please select 1 or 2 as part of this option.
What it means
Returned when the user, at the 'rename workspaces?' prompt during multi-state-to-TFC migration, typed something other than exactly '1' or '2'. The value must be one of those two literal choices; '1' means rename with a pattern, '2' means keep names as-is.
Source
Thrown at internal/command/meta_backend_migrate.go:956
return "", fmt.Errorf("Error asking for new state name: %s", err)
}
return name, nil
}
func (m *Meta) promptMultiStateMigrationPattern(sourceType string, appName string) (string, error) {
// This is not the first prompt a user would be presented with in the migration to TFC, so no
// guard on m.input is needed here.
renameWorkspaces, err := m.UIInput().Input(context.Background(), &terraform.InputOpts{
Id: "backend-migrate-multistate-to-tfc",
Query: fmt.Sprintf("[reset][bold][yellow]%s[reset]", "Would you like to rename your workspaces?"),
Description: fmt.Sprintf(strings.TrimSpace(tfcInputBackendMigrateMultiToMulti), sourceType, appName),
})
if err != nil {
return "", fmt.Errorf("Error asking for state migration action: %s", err)
}
if renameWorkspaces != "2" && renameWorkspaces != "1" {
return "", fmt.Errorf("Please select 1 or 2 as part of this option.")
}
if renameWorkspaces == "2" {
// this means they did not want to rename their workspaces, and we are
// 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 '*'")View on GitHub (pinned to c9def3e214)
Solutions
- Re-run init and type exactly '1' (rename with a pattern) or '2' (do not rename) at the prompt.
- If you do not want renaming, choose '2'.
- If automating, supply the exact token via a controlled pipe.
- Avoid -force/extra flags that do not apply to this prompt; the choice is strictly 1 or 2.
Example fix
// before // at prompt: type 'yes' -> error // after // at prompt: type '1' (rename) or '2' (keep names)
Defensive patterns
Strategy: validation
Validate before calling
// When automating the rename prompt, supply exactly '1' or '2'.
input := strings.TrimSpace(answer)
if input != "1" && input != "2" {
return fmt.Errorf("must answer 1 or 2")
}
_ = input Type guard
func isValidRenameChoice(s string) bool {
return s == "1" || s == "2"
} Prevention
- Answer the prompt with exactly '1' (rename) or '2' (keep names).
- Trim whitespace if piping answers programmatically.
- Do not type 'yes'/'no' — only the two numeric tokens are accepted.
- Read the prompt text to understand what 1 and 2 mean.
When it happens
Trigger: promptMultiStateMigrationPattern receives a renameWorkspaces value that is neither "1" nor "2" — e.g. '3', 'yes', '1 ', an empty string, or '12'. The guard `if renameWorkspaces != "2" && renameWorkspaces != "1"` fires.
Common situations: User misreads the prompt and types 'yes'/'no'; stray whitespace/newline; pasted multi-character answer; non-English locale confusion about the numeric choice.
Related errors
- The pattern must have an '*'
- The pattern '*' cannot be used more than once.
- Error asking for new state name: %s
- Invalid value: %s
- Provider download blocked due to policy violations. Please r
AI-assisted analysis of hashicorp/terraform@c9def3e214 (2026-08-07).
Data as JSON: /api/errors/2f10a00adea28dd0.
Report an issue: GitHub.