{"record":{"id":"3c3c7e35a65e0cf5","repo":"tobi/qmd","slug":"line-line-number-is-missing-a-lex-vec-hyde-i-3c3c7e","errorCode":null,"errorMessage":"Line ${line.number} is missing a lex:/vec:/hyde:/intent: prefix. Each line in a query document must start with one.","messagePattern":"Line (.+?) is missing a lex:/vec:/hyde:/intent: prefix\\. Each line in a query document must start with one\\.","errorType":"validation","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"src/cli/qmd.ts","lineNumber":2782,"sourceCode":"    if (match) {\n      const type = match[1]!.toLowerCase() as 'lex' | 'vec' | 'hyde';\n      const text = line.trimmed.slice(match[0].length).trim();\n      if (!text) {\n        throw new Error(`Line ${line.number} (${type}:) must include text.`);\n      }\n      if (/\\r|\\n/.test(text)) {\n        throw new Error(`Line ${line.number} (${type}:) contains a newline. Keep each query on a single line.`);\n      }\n      typed.push({ type, query: text, line: line.number });\n      continue;\n    }\n\n    if (rawLines.length === 1) {\n      // Single plain line -> implicit expand\n      return null;\n    }\n\n    throw new Error(`Line ${line.number} is missing a lex:/vec:/hyde:/intent: prefix. Each line in a query document must start with one.`);\n  }\n\n  // intent: alone is not a valid query — must have at least one search\n  if (intent && typed.length === 0) {\n    throw new Error('intent: cannot appear alone. Add at least one lex:, vec:, or hyde: line.');\n  }\n\n  return typed.length > 0 ? { searches: typed, intent } : null;\n}\n\nfunction search(query: string, opts: OutputOptions): void {\n  const db = getDb();\n\n  // Validate collection filter (supports multiple -c flags)\n  // Use default collections if none specified\n  const collectionNames = resolveCollectionFilter(opts.collection, true);\n\n  // Use large limit for --all, otherwise fetch more than needed and let outputResults filter","sourceCodeStart":2764,"sourceCodeEnd":2800,"githubUrl":"https://github.com/tobi/qmd/blob/dbfd0b4736aeaf761d1a16ca8e424f071df8feb9/src/cli/qmd.ts#L2764-L2800","documentation":"Thrown when parsing a multi-line query document where a line does not start with one of the required prefixes: lex:, vec:, hyde:, or intent:. The query-document format requires every line (after the first, which gets implicit expansion) to be explicitly typed so the CLI knows which retrieval strategy to use for it.","triggerScenarios":"Running `qmd query` with a multi-line query document (e.g. via a query file or multi-line argument) where at least one line lacks a lex:/vec:/hyde:/intent: prefix. A single plain line is implicitly expanded, but two or more lines forces strict prefix validation.","commonSituations":"Writing a multi-line query file for hybrid search and forgetting prefixes on the second line; upgrading from an older version that allowed plain multi-line queries; mixing a natural-language question with typed lines.","solutions":["Add a lex:, vec:, hyde:, or intent: prefix to the offending line (the error names the line number)","Collapse the query to a single plain line to get implicit expand behavior","Check the query-document syntax with `qmd query --help` or the skill docs"],"exampleFix":"# before\nhow do I chunk markdown\nvec:embedding models\n# after\nlex:how do I chunk markdown\nvec:embedding models","handlingStrategy":"validation","validationCode":"const PREFIX = /^(lex:|vec:|hyde:|intent:)/;\nfunction validateQueryDoc(raw: string): { ok: true } | { ok: false; line: number } {\n  const lines = raw.split(/\\r?\\n/).filter((l) => l.trim() !== \"\");\n  if (lines.length <= 1) return { ok: true };\n  for (let i = 0; i < lines.length; i++) {\n    if (!PREFIX.test(lines[i])) return { ok: false, line: i + 1 };\n  }\n  return { ok: true };\n}","typeGuard":"null","tryCatchPattern":"null","preventionTips":["Always prefix every line of a multi-line query document with lex:/vec:/hyde:/intent:","Keep single-line queries unprefixed to get implicit expansion","Validate query files in CI/scripts before passing them to `qmd query`"],"tags":["query-document","validation","cli"],"backgroundTag":"query-validation-failed","analyzedSha":"dbfd0b4736aeaf761d1a16ca8e424f071df8feb9","analyzedAt":"2026-08-28T18:07:46.628Z","schemaVersion":2},"datasetVersion":"2026-08-28T21:17:43.275Z"}