{"record":{"id":"dd0b601642da0991","repo":"hashicorp/terraform","slug":"the-workspace-name-q-is-not-allowed-the-name-mu-dd0b60","errorCode":null,"errorMessage":"\nThe workspace name %q is not allowed. The name must contain only URL safe\ncharacters, contain no path separators, and not be an empty string.\n","messagePattern":"\nThe workspace name %q is not allowed\\. The name must contain only URL safe\ncharacters, contain no path separators, and not be an empty string\\.\n","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/command/arguments/workspace_select.go","lineNumber":50,"sourceCode":"\tcmdFlags.BoolVar(&orCreate, \"or-create\", false, \"create workspace if it does not exist\")\n\tif err := cmdFlags.Parse(args); err != nil {\n\t\tdiags = diags.Append(tfdiags.Sourceless(\n\t\t\ttfdiags.Error,\n\t\t\t\"Failed to parse command-line flags\",\n\t\t\terr.Error(),\n\t\t))\n\t}\n\n\t// `workspace select` takes only one positional argument: workspace name.\n\targs = cmdFlags.Args()\n\tvar name string\n\tif len(args) == 0 {\n\t\tdiags = diags.Append(errors.New(\"Expected a single argument: NAME.\")) // Recreating pre-existing error from command package\n\t} else {\n\t\t// Obtain and validate name argument.\n\t\tname = args[0]\n\t\tif !ValidWorkspaceName(name) {\n\t\t\tdiags = diags.Append(fmt.Errorf(EnvInvalidName, name))\n\t\t}\n\n\t\t// Checking for extra arguments here, not with a len != 1 check above, allows the name to be returned\n\t\targs = args[1:]\n\t\tif len(args) != 0 {\n\t\t\tdiags = diags.Append(errors.New(\"Expected a single argument: NAME.\"))\n\t\t}\n\t}\n\n\treturn &WorkspaceSelect{\n\t\tWorkspace: Workspace{ViewType: ViewHuman},\n\t\tOrCreate:  orCreate,\n\t\tName:      name,\n\t}, diags\n}\n","sourceCodeStart":32,"sourceCodeEnd":66,"githubUrl":"https://github.com/hashicorp/terraform/blob/c9def3e214014c1188faabfc4a5bde5095139765/internal/command/arguments/workspace_select.go#L32-L66","documentation":"Emitted by `terraform workspace select` (workspace_select.go:49-50) when the given name fails `ValidWorkspaceName` (workspace.go:19-24): non-empty and equal to its `url.PathEscape`. Uses the same `EnvInvalidName` constant as `workspace new`. Note `select` validates the name, unlike `delete`.","triggerScenarios":"Calling `terraform workspace select <name>` (with or without `-or-create`) where the name is empty or contains non-URL-safe/path-separator characters.","commonSituations":"Selecting a workspace derived from a branch name containing `/`; passing an env var that is empty; shell globbing producing an invalid token.","solutions":["Supply a workspace name that already passed validation when it was created (letters, digits, `-`, `_`).","Sanitize derived names: strip or replace `/`, `\\`, spaces, colons before selecting.","List existing workspaces with `terraform workspace list` to copy the exact valid name."],"exampleFix":"# before\nterraform workspace select \"feature/auth\"\n# The workspace name \"feature/auth\" is not allowed ...\n\n# after\nterraform workspace list   # confirm the exact name\nterraform workspace select feature-auth","handlingStrategy":"validation","validationCode":"// Reuse the same check the CLI uses before 'workspace select'.\nimport \"net/url\"\n\nfunc validWorkspaceName(name string) bool {\n    return name != \"\" && name == url.PathEscape(name)\n}\n\n// Prefer selecting from the list of existing (already-valid) names:\n// terraform workspace list  -> pick an exact entry.","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Select only names returned by `terraform workspace list`.","Sanitize any derived name with the same rules as creation.","Treat an empty derived name as a hard error in automation."],"tags":["terraform","workspace","select","validation","naming"],"analyzedSha":"c9def3e214014c1188faabfc4a5bde5095139765","analyzedAt":"2026-08-07T15:39:49.278Z","schemaVersion":2},"datasetVersion":"2026-08-07T21:17:07.882Z"}