{"record":{"id":"504febb5295ea359","repo":"usebruno/bruno","slug":"invalid-workspace-directory-name-dirpath","errorCode":null,"errorMessage":"Invalid workspace directory name: ${dirPath}","messagePattern":"Invalid workspace directory name: (.+?)","errorType":"validation","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/bruno-electron/src/utils/workspace-config.js","lineNumber":186,"sourceCode":"  if (!workspacePath) {\n    throw new Error('Workspace path is required');\n  }\n\n  if (!fs.existsSync(workspacePath)) {\n    throw new Error(`Workspace path does not exist: ${workspacePath}`);\n  }\n\n  const workspaceFilePath = path.join(workspacePath, 'workspace.yml');\n  if (!fs.existsSync(workspaceFilePath)) {\n    throw new Error('Invalid workspace: workspace.yml not found');\n  }\n\n  return true;\n};\n\nconst validateWorkspaceDirectory = (dirPath) => {\n  if (!validateName(path.basename(dirPath))) {\n    throw new Error(`Invalid workspace directory name: ${dirPath}`);\n  }\n  return true;\n};\n\nconst createWorkspaceConfig = (workspaceName) => ({\n  opencollection: OPENCOLLECTION_VERSION,\n  info: {\n    name: workspaceName,\n    type: WORKSPACE_TYPE\n  },\n  collections: [],\n  specs: [],\n  docs: ''\n});\n\nconst normalizeWorkspaceConfig = (config) => {\n  // Coerce `specs` to an array once. A malformed workspace.yml (e.g. `specs`\n  // authored as a map) would otherwise flow through as a non-array and crash","sourceCodeStart":168,"sourceCodeEnd":204,"githubUrl":"https://github.com/usebruno/bruno/blob/9bdd81c7bdc57006e5f5ebffb79321a8d979f712/packages/bruno-electron/src/utils/workspace-config.js#L168-L204","documentation":"`validateWorkspaceDirectory` runs `validateName(path.basename(dirPath))` and throws when the directory's base name contains characters Bruno disallows. It is a name-sanitization guard used when creating/registering a workspace directory.","triggerScenarios":"Creating a workspace whose folder name fails `validateName` — typically disallowed characters or an empty/whitespace-only basename.","commonSituations":"Folder names with slashes, NULs, or OS-forbidden characters; a path that ended in a separator leaving an empty basename; copy-pasted names with quotes or control chars; non-normalized relative paths.","solutions":["Rename the folder to a clean, single-segment name with no special characters.","Normalize the path (`path.normalize`) before deriving the basename.","Generate the folder name from the workspace name using the same rules `validateName` enforces."],"exampleFix":"// before\nvalidateWorkspaceDirectory('/work/my \"bad\" workspace/');\n\n// after\nvalidateWorkspaceDirectory('/work/my-workspace');","handlingStrategy":"validation","validationCode":"const path = require('path');\nconst { validateName } = require('./filesystem');\nfunction ensureValidDirName(p) {\n  const base = path.basename(path.normalize(p));\n  if (!validateName(base)) throw new Error(`Invalid workspace directory name: ${base}`);\n  return p;\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Normalize paths before deriving the basename.","Restrict workspace names to alphanumerics, dash, underscore in the UI."],"tags":["workspace","filesystem","validation","naming"],"backgroundTag":null,"analyzedSha":"9bdd81c7bdc57006e5f5ebffb79321a8d979f712","analyzedAt":"2026-08-13T04:09:25.751Z","schemaVersion":2},"datasetVersion":"2026-08-13T04:17:16.726Z"}