{"record":{"id":"1a72507e62f5c6b8","repo":"tobi/qmd","slug":"invalid-fixture-missing-queries-array","errorCode":null,"errorMessage":"Invalid fixture: missing 'queries' array","messagePattern":"Invalid fixture: missing 'queries' array","errorType":"validation","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"src/bench/bench.ts","lineNumber":341,"sourceCode":"}\n\nexport async function runBenchmark(\n  fixturePath: string,\n  options: {\n    json?: boolean;\n    collection?: string;\n    backends?: string[];\n    dbPath?: string;\n    configPath?: string;\n    config?: import(\"../collections.js\").CollectionConfig;\n  } = {},\n): Promise<BenchmarkResult> {\n  // Load fixture\n  const raw = readFileSync(resolve(fixturePath), \"utf-8\");\n  const fixture: BenchmarkFixture = JSON.parse(raw);\n\n  if (!fixture.queries || !Array.isArray(fixture.queries)) {\n    throw new Error(\"Invalid fixture: missing 'queries' array\");\n  }\n\n  // Open store\n  const store = await createStore({\n    dbPath: options.dbPath ?? getDefaultDbPath(),\n    ...(options.configPath ? { configPath: options.configPath } : {}),\n    ...(options.config ? { config: options.config } : {}),\n  });\n\n  // Filter backends if requested\n  const activeBackends = options.backends\n    ? BACKENDS.filter(b => options.backends!.includes(b.name))\n    : BACKENDS;\n\n  const collection = options.collection ?? fixture.collection;\n\n  const results: QueryResult[] = [];\n  try {","sourceCodeStart":323,"sourceCodeEnd":359,"githubUrl":"https://github.com/tobi/qmd/blob/dbfd0b4736aeaf761d1a16ca8e424f071df8feb9/src/bench/bench.ts#L323-L359","documentation":"Thrown by runBenchmark when the fixture JSON file parses but has no 'queries' array (or queries is not an array). The fixture schema requires a top-level queries array of benchmark query objects.","triggerScenarios":"Passing a JSON file like {\"query\": \"...\"} or {\"queries\": {}} to `qmd bench`; malformed hand-written fixture; wrong file passed as fixture.","commonSituations":"Editing fixture by hand and forgetting the array; passing a search-results JSON instead of a fixture; schema drift after upgrading qmd's bench format.","solutions":["Ensure the file contains \"queries\": [ ... ] as a top-level JSON array","Copy an existing working fixture and edit its queries entries","Validate the JSON with `jq '.queries | type'` expecting \"array\""],"exampleFix":"// before\n{ \"query\": \"lex: install\" }\n// after\n{ \"queries\": [ { \"query\": \"lex: install\", \"expected_files\": [\"README.md\"] } ] }","handlingStrategy":"type-guard","validationCode":"const fx = JSON.parse(raw);\nif (!fx || !Array.isArray(fx.queries)) throw new TypeError('fixture missing queries[]');","typeGuard":"const isBenchFixture = (v: unknown): v is { queries: unknown[] } => typeof v === 'object' && v !== null && Array.isArray((v as any).queries);","tryCatchPattern":"try { JSON.parse(raw) } catch { throw new Error('fixture is not valid JSON'); }","preventionTips":["Validate fixtures with a JSON schema or type guard before qmd bench","Generate fixtures programmatically rather than hand-editing JSON"],"tags":["bench","fixture-validation","json"],"backgroundTag":"schema-validation-failed","analyzedSha":"dbfd0b4736aeaf761d1a16ca8e424f071df8feb9","analyzedAt":"2026-08-28T18:07:46.628Z","schemaVersion":2},"datasetVersion":"2026-08-28T21:17:43.275Z"}