{"record":{"id":"12f0a273aaf47c8d","repo":"tobi/qmd","slug":"expand-query-must-include-text","errorCode":null,"errorMessage":"expand: query must include text.","messagePattern":"expand: query must include text\\.","errorType":"validation","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"src/cli/qmd.ts","lineNumber":2745,"sourceCode":"    number: idx + 1,\n  })).filter(line => line.trimmed.length > 0);\n\n  if (rawLines.length === 0) return null;\n\n  const prefixRe = /^(lex|vec|hyde):\\s*/i;\n  const expandRe = /^expand:\\s*/i;\n  const intentRe = /^intent:\\s*/i;\n  const typed: ExpandedQuery[] = [];\n  let intent: string | undefined;\n\n  for (const line of rawLines) {\n    if (expandRe.test(line.trimmed)) {\n      if (rawLines.length > 1) {\n        throw new Error(`Line ${line.number} starts with expand:, but query documents cannot mix expand with typed lines. Submit a single expand query instead.`);\n      }\n      const text = line.trimmed.replace(expandRe, '').trim();\n      if (!text) {\n        throw new Error('expand: query must include text.');\n      }\n      return null; // treat as standalone expand query\n    }\n\n    // Parse intent: lines\n    if (intentRe.test(line.trimmed)) {\n      if (intent !== undefined) {\n        throw new Error(`Line ${line.number}: only one intent: line is allowed per query document.`);\n      }\n      const text = line.trimmed.replace(intentRe, '').trim();\n      if (!text) {\n        throw new Error(`Line ${line.number}: intent: must include text.`);\n      }\n      intent = text;\n      continue;\n    }\n\n    const match = line.trimmed.match(prefixRe);","sourceCodeStart":2727,"sourceCodeEnd":2763,"githubUrl":"https://github.com/tobi/qmd/blob/dbfd0b4736aeaf761d1a16ca8e424f071df8feb9/src/cli/qmd.ts#L2727-L2763","documentation":"Thrown by the CLI query-document parser when a standalone expand: line has no text after the colon. The expand query needs the natural-language description to feed LLM query expansion.","triggerScenarios":"Piping 'expand:' or 'expand:   ' as the query document to `qmd query`.","commonSituations":"Empty variable expansion in scripts (`echo \"expand: $Q\"` with Q unset); placeholder text never replaced.","solutions":["Add the topic text: 'expand: how to set up vector search'","Ensure script variables are set before interpolating into the query"],"exampleFix":"# before\nprintf 'expand:' | qmd query\n# after\nprintf 'expand: how to set up vector search' | qmd query","handlingStrategy":"validation","validationCode":"if (/^\\s*expand:\\s*$/im.test(doc)) throw new Error('expand: line has no text');","typeGuard":"const expandHasText = (doc: string) => !/^\\s*expand:\\s*$/im.test(doc);","tryCatchPattern":null,"preventionTips":["Default query variables in scripts before interpolating into expand: lines"],"tags":["query","cli","query-syntax"],"backgroundTag":"query-syntax-validation-failed","analyzedSha":"dbfd0b4736aeaf761d1a16ca8e424f071df8feb9","analyzedAt":"2026-08-28T18:07:46.628Z","schemaVersion":2},"datasetVersion":"2026-08-28T21:17:43.275Z"}