usebruno/bruno · error · Error

Unable to parse opencollection.yml: ${err.message}

Error message

Unable to parse opencollection.yml: ${err.message}

What it means

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.

Source

Thrown at packages/bruno-electron/src/app/collections.js:73

    await configSchema.validate(config);
  } catch (err) {
    return Promise.reject(new Error('bruno.json format is invalid in ' + config?.name));
  }
};

const getCollectionConfigFile = async (pathname) => {
  // Check for opencollection.yml first
  const ocYmlPath = path.join(pathname, 'opencollection.yml');
  if (fs.existsSync(ocYmlPath)) {
    try {
      const content = fs.readFileSync(ocYmlPath, 'utf8');
      const {
        brunoConfig
      } = parseCollection(content, { format: 'yml' });
      await validateSchema(brunoConfig);
      return brunoConfig;
    } catch (err) {
      throw new Error(`Unable to parse opencollection.yml: ${err.message}`);
    }
  }

  // Fall back to bruno.json
  const configFilePath = path.join(pathname, 'bruno.json');
  if (!fs.existsSync(configFilePath)) {
    throw new Error(`The collection is not valid (neither bruno.json nor opencollection.yml found)`);
  }

  const config = await readConfigFile(configFilePath);
  await validateSchema(config);

  return config;
};

const openCollection = async (win, watcher, collectionPath, options = {}) => {
  // If watcher already exists, collection is already loaded in the app
  // Just send the collection info so frontend can add to workspace if needed

View on GitHub (pinned to 9bdd81c7bd)

Solutions

  1. Read the appended err.message — a YAML parser error names the line/column; a schema error names the field.
  2. Validate the YAML with a linter and confirm the top-level has a `brunoConfig:` key whose value matches the collection config schema.
  3. If unrecoverable, delete opencollection.yml and use bruno.json instead.

Example fix

# before — opencollection.yml (invalid: tabs, missing brunoConfig key)
name: My Collection
	type: collection

# after
brunoConfig:
  name: My Collection
  type: collection
  meta:
    version: '1.0'
Defensive patterns

Strategy: validation

Validate before calling

import YAML from 'yaml';
const preflight = (content) => {
  const parsed = YAML.parse(content);
  if (!parsed?.brunoConfig) throw new Error('opencollection.yml must have a brunoConfig key');
};

Type guard

const isOpenCollectionYml = (content) => {
  try { return !!YAML.parse(content)?.brunoConfig; } catch { return false; }
};

Try / catch

try {
  return await getCollectionConfigFile(dir);
} catch (e) {
  if (/Unable to parse opencollection\.yml/.test(e.message)) {
    // fall back: rename/repair the file or use bruno.json
  }
  throw e;
}

Prevention

When it happens

Trigger: 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`).

Common situations: 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.

Understand the failure class

Related errors


AI-assisted analysis of usebruno/bruno@9bdd81c7bd (2026-08-13). Data as JSON: /api/errors/9ab05d2ea0407d64. Report an issue: GitHub.