{"record":{"id":"e827135af546187a","repo":"usebruno/bruno","slug":"the-collection-is-not-valid-neither-bruno-json-no","errorCode":null,"errorMessage":"The collection is not valid (neither bruno.json nor opencollection.yml found)","messagePattern":"The collection is not valid \\(neither bruno\\.json nor opencollection\\.yml found\\)","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/bruno-electron/src/app/collections.js","lineNumber":80,"sourceCode":"  // Check for opencollection.yml first\n  const ocYmlPath = path.join(pathname, 'opencollection.yml');\n  if (fs.existsSync(ocYmlPath)) {\n    try {\n      const content = fs.readFileSync(ocYmlPath, 'utf8');\n      const {\n        brunoConfig\n      } = parseCollection(content, { format: 'yml' });\n      await validateSchema(brunoConfig);\n      return brunoConfig;\n    } catch (err) {\n      throw new Error(`Unable to parse opencollection.yml: ${err.message}`);\n    }\n  }\n\n  // Fall back to bruno.json\n  const configFilePath = path.join(pathname, 'bruno.json');\n  if (!fs.existsSync(configFilePath)) {\n    throw new Error(`The collection is not valid (neither bruno.json nor opencollection.yml found)`);\n  }\n\n  const config = await readConfigFile(configFilePath);\n  await validateSchema(config);\n\n  return config;\n};\n\nconst openCollection = async (win, watcher, collectionPath, options = {}) => {\n  // If watcher already exists, collection is already loaded in the app\n  // Just send the collection info so frontend can add to workspace if needed\n  if (watcher.hasWatcher(collectionPath)) {\n    try {\n      let brunoConfig = await getCollectionConfigFile(collectionPath);\n      const uid = generateUidBasedOnHash(collectionPath);\n      brunoConfig = await transformBrunoConfigAfterRead(brunoConfig, collectionPath);\n      const { size, filesCount } = await getCollectionStats(collectionPath);\n      brunoConfig.size = size;","sourceCodeStart":62,"sourceCodeEnd":98,"githubUrl":"https://github.com/usebruno/bruno/blob/9bdd81c7bdc57006e5f5ebffb79321a8d979f712/packages/bruno-electron/src/app/collections.js#L62-L98","documentation":"Thrown by getCollectionConfigFile when neither opencollection.yml nor bruno.json exists in the target collection directory. The function checks opencollection.yml first, then falls back to bruno.json; if neither file is present via fs.existsSync, the directory is treated as not a valid Bruno collection. This is a directory-contents guard, not a content check.","triggerScenarios":"Calling openCollection on a path that has no config file — e.g. a loose folder of .bru files, a freshly cloned repo missing its bruno.json, a path pointing at the wrong directory, or a collection that was never initialized.","commonSituations":"Opening a directory that contains request files but no bruno.json/opencollection.yml; mistyped collection path; migration in progress where the config was deleted; git ignoring bruno.json.","solutions":["Initialize the collection: run Bruno's 'Create Collection' or add a bruno.json manually.","Verify the path is the collection root (the folder that should contain bruno.json), not a parent or subfolder.","If migrating, create an opencollection.yml or bruno.json before opening."],"exampleFix":"// before\nopenCollection(win, watcher, '/repo/requests'); // no bruno.json here\n\n// after — point at the collection root, or create the config\n// bruno.json contents:\n{\n  \"name\": \"My Collection\",\n  \"type\": \"collection\",\n  \"meta\": { \"version\": \"1.0\" }\n}","handlingStrategy":"validation","validationCode":"const fs = require('fs'), path = require('path');\nconst hasCollectionConfig = (dir) =>\n  fs.existsSync(path.join(dir, 'opencollection.yml')) ||\n  fs.existsSync(path.join(dir, 'bruno.json'));","typeGuard":"const isBrunoCollectionDir = (dir) =>\n  fs.existsSync(path.join(dir, 'opencollection.yml')) ||\n  fs.existsSync(path.join(dir, 'bruno.json'));","tryCatchPattern":null,"preventionTips":["Initialize collections with Bruno's create flow so bruno.json exists.","Confirm the path is the collection root, not a subfolder.","Ensure bruno.json is committed to git."],"tags":["collection","config","bruno-electron","filesystem","missing-file"],"backgroundTag":null,"analyzedSha":"9bdd81c7bdc57006e5f5ebffb79321a8d979f712","analyzedAt":"2026-08-13T04:09:25.751Z","schemaVersion":2},"datasetVersion":"2026-08-13T04:17:16.726Z"}