{"record":{"id":"51dab13e35d6f0fb","repo":"tobi/qmd","slug":"collection-not-found-collection-n-hint","errorCode":null,"errorMessage":"Collection not found: ${collection}\\n${hint}","messagePattern":"Collection not found: (.+?)\\\\n(.+?)","errorType":"validation","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"src/bench/bench.ts","lineNumber":294,"sourceCode":"  active_count: number;\n};\n\n/**\n * Fail fast when the fixture's collection is missing or empty so `qmd bench`\n * does not spend minutes printing a wall of 0.00 (#716).\n */\nexport function assertBenchCollectionReady(\n  collections: BenchCollectionInfo[],\n  collection?: string,\n): void {\n  if (collection) {\n    const match = collections.find(c => c.name === collection);\n    if (!match) {\n      const names = collections.map(c => c.name);\n      const hint = names.length > 0\n        ? `Available: ${names.join(\", \")}. Run 'qmd ls' to inspect.`\n        : \"Run 'qmd ls' to see available collections.\";\n      throw new Error(`Collection not found: ${collection}\\n${hint}`);\n    }\n    if (match.active_count === 0) {\n      throw new Error(\n        `Collection '${collection}' has no indexed documents.\\nRun 'qmd update', then 'qmd ls ${collection}' to confirm files are indexed before bench.`,\n      );\n    }\n    return;\n  }\n\n  const total = collections.reduce((n, c) => n + c.active_count, 0);\n  if (collections.length === 0 || total === 0) {\n    throw new Error(\n      \"No indexed documents found.\\nIndex a collection with 'qmd collection add' / 'qmd update' before running bench.\",\n    );\n  }\n}\n\nexport function benchSummaryAllZero(","sourceCodeStart":276,"sourceCodeEnd":312,"githubUrl":"https://github.com/tobi/qmd/blob/dbfd0b4736aeaf761d1a16ca8e424f071df8feb9/src/bench/bench.ts#L276-L312","documentation":"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.","triggerScenarios":"Running `qmd bench fixture.json -c mynotes` when the indexed collection is named 'notes' or 'my-notes'.","commonSituations":"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.","solutions":["Run `qmd collection list` (or `qmd ls`) and use the exact name shown","If the collection is missing, add it: `qmd collection add <path> --name <name>` then `qmd update`","If the name changed, `qmd collection rename <old> <new>` or update the bench command"],"exampleFix":"# before\nqmd bench bench/fixture.json -c mynotes\n# after\nqmd bench bench/fixture.json -c notes","handlingStrategy":"validation","validationCode":"import { execSync } from 'node:child_process';\nconst names = JSON.parse(execSync('qmd collection list --format json').toString()).map(c => c.name);\nif (!names.includes(name)) throw new Error(`unknown collection ${name}; have: ${names.join(', ')}`);","typeGuard":"const isKnownCollection = (names: string[], n: string) => names.includes(n);","tryCatchPattern":"try { await runBenchmark(...) } catch (e) { if (String(e.message).startsWith('Collection not found')) { /* list collections, prompt user */ } throw e; }","preventionTips":["Resolve collection names from `qmd collection list` at runtime instead of hardcoding","Fail fast in scripts when the collection list is empty"],"tags":["bench","collection","cli"],"backgroundTag":"resource-not-found","analyzedSha":"dbfd0b4736aeaf761d1a16ca8e424f071df8feb9","analyzedAt":"2026-08-28T18:07:46.628Z","schemaVersion":2},"datasetVersion":"2026-08-28T21:17:43.275Z"}