tobi/qmd · error · Error
Invalid fixture: missing 'queries' array
Error message
Invalid fixture: missing 'queries' array
What it means
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.
Source
Thrown at src/bench/bench.ts:341
}
export async function runBenchmark(
fixturePath: string,
options: {
json?: boolean;
collection?: string;
backends?: string[];
dbPath?: string;
configPath?: string;
config?: import("../collections.js").CollectionConfig;
} = {},
): Promise<BenchmarkResult> {
// Load fixture
const raw = readFileSync(resolve(fixturePath), "utf-8");
const fixture: BenchmarkFixture = JSON.parse(raw);
if (!fixture.queries || !Array.isArray(fixture.queries)) {
throw new Error("Invalid fixture: missing 'queries' array");
}
// Open store
const store = await createStore({
dbPath: options.dbPath ?? getDefaultDbPath(),
...(options.configPath ? { configPath: options.configPath } : {}),
...(options.config ? { config: options.config } : {}),
});
// Filter backends if requested
const activeBackends = options.backends
? BACKENDS.filter(b => options.backends!.includes(b.name))
: BACKENDS;
const collection = options.collection ?? fixture.collection;
const results: QueryResult[] = [];
try {View on GitHub (pinned to dbfd0b4736)
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"
Example fix
// before
{ "query": "lex: install" }
// after
{ "queries": [ { "query": "lex: install", "expected_files": ["README.md"] } ] } Defensive patterns
Strategy: type-guard
Validate before calling
const fx = JSON.parse(raw);
if (!fx || !Array.isArray(fx.queries)) throw new TypeError('fixture missing queries[]'); Type guard
const isBenchFixture = (v: unknown): v is { queries: unknown[] } => typeof v === 'object' && v !== null && Array.isArray((v as any).queries); Try / catch
try { JSON.parse(raw) } catch { throw new Error('fixture is not valid JSON'); } Prevention
- Validate fixtures with a JSON schema or type guard before qmd bench
- Generate fixtures programmatically rather than hand-editing JSON
When it happens
Trigger: Passing a JSON file like {"query": "..."} or {"queries": {}} to `qmd bench`; malformed hand-written fixture; wrong file passed as fixture.
Common situations: 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.
Understand the failure class
Background: Schema validation failed / invalid input schema: payload rejected because its shape doesn't match the expected schema — this error's family across 28 libraries.
Related errors
- Line ${line.number}: only one intent: line is allowed per be
- Line ${line.number}: intent: must include text.
- Line ${line.number} (${type}:) must include text.
- Line ${line.number} is missing a lex:/vec:/hyde:/intent: pre
- intent: cannot appear alone. Add at least one lex:, vec:, or
AI-assisted analysis of tobi/qmd@dbfd0b4736 (2026-08-28).
Data as JSON: /api/errors/1a72507e62f5c6b8.
Report an issue: GitHub.