{"record":{"id":"b5e0dc3ff42e4a66","repo":"usebruno/bruno","slug":"invalid-collection-name-and-path-are-required","errorCode":null,"errorMessage":"Invalid collection: name and path are required","messagePattern":"Invalid collection: name and path are required","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/bruno-electron/src/utils/workspace-config.js","lineNumber":339,"sourceCode":"    const yamlContent = generateYamlContent(config);\n    await writeWorkspaceFileAtomic(workspacePath, yamlContent);\n    return config;\n  });\n};\n\nconst updateWorkspaceDocs = async (workspacePath, docs) => {\n  return withLock(getWorkspaceLockKey(workspacePath), async () => {\n    const config = readWorkspaceConfig(workspacePath);\n    config.docs = docs;\n    const yamlContent = generateYamlContent(config);\n    await writeWorkspaceFileAtomic(workspacePath, yamlContent);\n    return docs;\n  });\n};\n\nconst addCollectionToWorkspace = async (workspacePath, collection) => {\n  if (!isValidCollectionEntry(collection)) {\n    throw new Error('Invalid collection: name and path are required');\n  }\n\n  return withLock(getWorkspaceLockKey(workspacePath), async () => {\n    const config = readWorkspaceConfig(workspacePath);\n\n    if (!config.collections) {\n      config.collections = [];\n    }\n\n    const normalizedCollection = {\n      name: collection.name.trim(),\n      path: posixifyPath(collection.path.trim())\n    };\n\n    if (collection.remote && typeof collection.remote === 'string') {\n      normalizedCollection.remote = collection.remote.trim();\n    }\n","sourceCodeStart":321,"sourceCodeEnd":357,"githubUrl":"https://github.com/usebruno/bruno/blob/9bdd81c7bdc57006e5f5ebffb79321a8d979f712/packages/bruno-electron/src/utils/workspace-config.js#L321-L357","documentation":"`addCollectionToWorkspace` runs `isValidCollectionEntry`, which requires an object with non-empty trimmed `name` and `path` strings; otherwise it throws before acquiring the workspace lock.","triggerScenarios":"Calling `addCollectionToWorkspace(workspacePath, collection)` where `collection` is not an object, or where `name`/`path` is missing, empty, or non-string.","commonSituations":"UI form submitted with a blank collection name or path; a programmatic caller that built the entry with undefined fields; passing a relative path that got normalized to empty; copy of an entry that lost fields.","solutions":["Ensure `collection.name` is a non-empty trimmed string.","Ensure `collection.path` is a non-empty trimmed string (absolute or resolvable).","Build the entry through a factory that fills both fields, validating before submit."],"exampleFix":"// before\nawait addCollectionToWorkspace(wsPath, { name: 'API' });\n\n// after\nawait addCollectionToWorkspace(wsPath, { name: 'API', path: '/work/ws/api' });","handlingStrategy":"validation","validationCode":"function isValidCollectionEntry(c) {\n  return !!c && typeof c === 'object'\n    && typeof c.name === 'string' && c.name.trim() !== ''\n    && typeof c.path === 'string' && c.path.trim() !== '';\n}\nif (!isValidCollectionEntry(entry)) throw new Error('name and path required');","typeGuard":"function isCollectionEntry(c: unknown): c is { name: string; path: string } {\n  if (!c || typeof c !== 'object') return false;\n  const o = c as any;\n  return typeof o.name === 'string' && o.name.trim() !== ''\n      && typeof o.path === 'string' && o.path.trim() !== '';\n}","tryCatchPattern":null,"preventionTips":["Disable the submit button until both fields are non-empty.","Resolve paths to absolute strings before constructing the entry."],"tags":["workspace","collection","validation","config"],"backgroundTag":null,"analyzedSha":"9bdd81c7bdc57006e5f5ebffb79321a8d979f712","analyzedAt":"2026-08-13T04:09:25.751Z","schemaVersion":2},"datasetVersion":"2026-08-13T04:17:16.726Z"}