tobi/qmd · error · Error

Collection not found: ${collection}\n${hint}

Error message

Collection not found: ${collection}\n${hint}

What it means

Thrown by assertBenchCollectionReady when qmd bench is run with a -c/--collection name that does not match any collection in the index. The message lists available collection names to help correct the typo.

Source

Thrown at src/bench/bench.ts:294

  active_count: number;
};

/**
 * Fail fast when the fixture's collection is missing or empty so `qmd bench`
 * does not spend minutes printing a wall of 0.00 (#716).
 */
export function assertBenchCollectionReady(
  collections: BenchCollectionInfo[],
  collection?: string,
): void {
  if (collection) {
    const match = collections.find(c => c.name === collection);
    if (!match) {
      const names = collections.map(c => c.name);
      const hint = names.length > 0
        ? `Available: ${names.join(", ")}. Run 'qmd ls' to inspect.`
        : "Run 'qmd ls' to see available collections.";
      throw new Error(`Collection not found: ${collection}\n${hint}`);
    }
    if (match.active_count === 0) {
      throw new Error(
        `Collection '${collection}' has no indexed documents.\nRun 'qmd update', then 'qmd ls ${collection}' to confirm files are indexed before bench.`,
      );
    }
    return;
  }

  const total = collections.reduce((n, c) => n + c.active_count, 0);
  if (collections.length === 0 || total === 0) {
    throw new Error(
      "No indexed documents found.\nIndex a collection with 'qmd collection add' / 'qmd update' before running bench.",
    );
  }
}

export function benchSummaryAllZero(

View on GitHub (pinned to dbfd0b4736)

Solutions

  1. Run `qmd collection list` (or `qmd ls`) and use the exact name shown
  2. If the collection is missing, add it: `qmd collection add <path> --name <name>` then `qmd update`
  3. If the name changed, `qmd collection rename <old> <new>` or update the bench command

Example fix

# before
qmd bench bench/fixture.json -c mynotes
# after
qmd bench bench/fixture.json -c notes
Defensive patterns

Strategy: validation

Validate before calling

import { execSync } from 'node:child_process';
const names = JSON.parse(execSync('qmd collection list --format json').toString()).map(c => c.name);
if (!names.includes(name)) throw new Error(`unknown collection ${name}; have: ${names.join(', ')}`);

Type guard

const isKnownCollection = (names: string[], n: string) => names.includes(n);

Try / catch

try { await runBenchmark(...) } catch (e) { if (String(e.message).startsWith('Collection not found')) { /* list collections, prompt user */ } throw e; }

Prevention

When it happens

Trigger: Running `qmd bench fixture.json -c mynotes` when the indexed collection is named 'notes' or 'my-notes'.

Common situations: Typos or wrong casing in the collection flag; renaming a collection after the bench script was written; running against a fresh machine whose global index has different collection names.

Understand the failure class

Background: 'Could not be found', 'does not exist', 'not found in database': the resource-not-found family when an ID, slug, key, or URI lookup comes back empty — this error's family across 20 libraries.

Related errors


AI-assisted analysis of tobi/qmd@dbfd0b4736 (2026-08-28). Data as JSON: /api/errors/51dab13e35d6f0fb. Report an issue: GitHub.