{"record":{"id":"9ab05d2ea0407d64","repo":"usebruno/bruno","slug":"unable-to-parse-opencollection-yml-err-message","errorCode":null,"errorMessage":"Unable to parse opencollection.yml: ${err.message}","messagePattern":"Unable to parse opencollection\\.yml: (.+?)","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/bruno-electron/src/app/collections.js","lineNumber":73,"sourceCode":"    await configSchema.validate(config);\n  } catch (err) {\n    return Promise.reject(new Error('bruno.json format is invalid in ' + config?.name));\n  }\n};\n\nconst getCollectionConfigFile = async (pathname) => {\n  // 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","sourceCodeStart":55,"sourceCodeEnd":91,"githubUrl":"https://github.com/usebruno/bruno/blob/9bdd81c7bdc57006e5f5ebffb79321a8d979f712/packages/bruno-electron/src/app/collections.js#L55-L91","documentation":"Thrown by getCollectionConfigFile when reading and parsing opencollection.yml fails — either parseCollection (YAML parse) or the subsequent validateSchema (bruno.json/opencollection schema) rejects. The original error message is appended, so the suffix usually indicates whether it was a YAML syntax error or a schema violation. This only fires when opencollection.yml exists; bruno.json fallback is separate.","triggerScenarios":"opencollection.yml exists but contains invalid YAML (bad indentation, tabs), or parses but its brunoConfig sub-object fails the collection config schema (missing required `name`, unknown `type`, bad `meta`).","commonSituations":"Hand-edited opencollection.yml with tab characters (YAML forbids tabs); missing `brunoConfig:` wrapper key; schema version drift after a Bruno update that renamed/required fields; copy-paste from bruno.json without converting JSON->YAML structure.","solutions":["Read the appended err.message — a YAML parser error names the line/column; a schema error names the field.","Validate the YAML with a linter and confirm the top-level has a `brunoConfig:` key whose value matches the collection config schema.","If unrecoverable, delete opencollection.yml and use bruno.json instead."],"exampleFix":"# before — opencollection.yml (invalid: tabs, missing brunoConfig key)\nname: My Collection\n\ttype: collection\n\n# after\nbrunoConfig:\n  name: My Collection\n  type: collection\n  meta:\n    version: '1.0'","handlingStrategy":"validation","validationCode":"import YAML from 'yaml';\nconst preflight = (content) => {\n  const parsed = YAML.parse(content);\n  if (!parsed?.brunoConfig) throw new Error('opencollection.yml must have a brunoConfig key');\n};","typeGuard":"const isOpenCollectionYml = (content) => {\n  try { return !!YAML.parse(content)?.brunoConfig; } catch { return false; }\n};","tryCatchPattern":"try {\n  return await getCollectionConfigFile(dir);\n} catch (e) {\n  if (/Unable to parse opencollection\\.yml/.test(e.message)) {\n    // fall back: rename/repair the file or use bruno.json\n  }\n  throw e;\n}","preventionTips":["Use spaces (not tabs) and a YAML linter when editing opencollection.yml.","Always wrap config in a top-level `brunoConfig:` key.","Validate the structure against the collection config schema after edits."],"tags":["collection","yaml","config","bruno-electron","schema-validation"],"backgroundTag":null,"analyzedSha":"9bdd81c7bdc57006e5f5ebffb79321a8d979f712","analyzedAt":"2026-08-13T04:09:25.751Z","schemaVersion":2},"datasetVersion":"2026-08-13T04:17:16.726Z"}