{"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/d32a084675427f5ac3f7d2868578ef8b2c1dc525/internal/command/arguments/workspace_select.go#L32-L66","documentation":"Thrown by terraform workspace select when the workspace name fails ValidWorkspaceName. Identical validation to workspace new: the name must be non-empty and equal to its url.PathEscape output, meaning only URL-safe characters with no path separators.","triggerScenarios":"Running terraform workspace select <name> where name contains characters that fail the PathEscape comparison (slashes, spaces, special characters) or is empty. The !ValidWorkspaceName(name) check triggers the error.","commonSituations":"Selecting a workspace by a path-like name (team/prod); using a name with special characters; empty string from environment variable; typo including a slash character.","solutions":["Correct the workspace name to use only URL-safe characters","List available workspaces with terraform workspace list to find the correct name","Remove path separators and special characters from the name"],"exampleFix":"# before\nterraform workspace select \"prod/env\"\n\n# after\nterraform workspace select \"prod-env\"","handlingStrategy":"validation","validationCode":"// Validate workspace name before terraform workspace select\nfunc validWorkspaceName(name string) bool {\n    if name == \"\" {\n        return false\n    }\n    return name == url.PathEscape(name)\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Check workspace name format before selecting","Use terraform workspace list to verify available names","Avoid path-like separators in workspace names","Validate with url.PathEscape equivalence to match Terraform's rule"],"tags":["workspace","validation","url-safe","naming"],"backgroundTag":null,"analyzedSha":"d32a084675427f5ac3f7d2868578ef8b2c1dc525","analyzedAt":"2026-08-11T18:43:52.779Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}