usebruno/bruno · error · Error

The collection is not valid (neither bruno.json nor opencoll

Error message

The collection is not valid (neither bruno.json nor opencollection.yml found)

What it means

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.

Source

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

  // 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
  if (watcher.hasWatcher(collectionPath)) {
    try {
      let brunoConfig = await getCollectionConfigFile(collectionPath);
      const uid = generateUidBasedOnHash(collectionPath);
      brunoConfig = await transformBrunoConfigAfterRead(brunoConfig, collectionPath);
      const { size, filesCount } = await getCollectionStats(collectionPath);
      brunoConfig.size = size;

View on GitHub (pinned to 9bdd81c7bd)

Solutions

  1. Initialize the collection: run Bruno's 'Create Collection' or add a bruno.json manually.
  2. Verify the path is the collection root (the folder that should contain bruno.json), not a parent or subfolder.
  3. If migrating, create an opencollection.yml or bruno.json before opening.

Example fix

// before
openCollection(win, watcher, '/repo/requests'); // no bruno.json here

// after — point at the collection root, or create the config
// bruno.json contents:
{
  "name": "My Collection",
  "type": "collection",
  "meta": { "version": "1.0" }
}
Defensive patterns

Strategy: validation

Validate before calling

const fs = require('fs'), path = require('path');
const hasCollectionConfig = (dir) =>
  fs.existsSync(path.join(dir, 'opencollection.yml')) ||
  fs.existsSync(path.join(dir, 'bruno.json'));

Type guard

const isBrunoCollectionDir = (dir) =>
  fs.existsSync(path.join(dir, 'opencollection.yml')) ||
  fs.existsSync(path.join(dir, 'bruno.json'));

Prevention

When it happens

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

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

Related errors


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