tobi/qmd · error · Error
--chunk-strategy must be "auto" or "regex" (got "${s}")
Error message
--chunk-strategy must be "auto" or "regex" (got "${s}") What it means
Thrown by parseChunkStrategy when --chunk-strategy is given a value other than the two supported strategies: 'auto' (AST-aware chunking for code files) or 'regex' (default).
Source
Thrown at src/cli/qmd.ts:2100
const empty = width - filled;
const bar = "█".repeat(filled) + "░".repeat(empty);
return bar;
}
function parseEmbedBatchOption(name: string, value: unknown): number | undefined {
if (value === undefined) return undefined;
const parsed = Number(value);
if (!Number.isInteger(parsed) || parsed < 1) {
throw new Error(`${name} must be a positive integer`);
}
return parsed;
}
function parseChunkStrategy(value: unknown): ChunkStrategy | undefined {
if (value === undefined) return undefined;
const s = String(value);
if (s === "auto" || s === "regex") return s;
throw new Error(`--chunk-strategy must be "auto" or "regex" (got "${s}")`);
}
// --timeout for `qmd embed`: a cap on the whole embed session, in minutes. Returns
// the value in milliseconds, or undefined to use the default. 0 disables the cap.
function parseEmbedTimeoutOption(value: unknown): number | undefined {
if (value === undefined) return undefined;
const minutes = Number(value);
if (!Number.isFinite(minutes) || minutes < 0) {
throw new Error(`--timeout must be a non-negative number of minutes (0 = no limit)`);
}
return minutes * 60 * 1000;
}
function ensureModelsConfiguredForCli(): { embed: string; generate: string; rerank: string } {
try {
const config = loadConfig();
const models = resolveModels(config.models);
const current = config.models ?? {};View on GitHub (pinned to dbfd0b4736)
Solutions
- Use `--chunk-strategy auto` or `--chunk-strategy regex`
- Omit the flag to keep the default regex strategy
- Check `qmd collection add --help` for the current accepted values
Example fix
# before qmd collection add . --name docs --chunk-strategy ast # after qmd collection add . --name docs --chunk-strategy auto
Defensive patterns
Strategy: type-guard
Validate before calling
if (!['auto', 'regex'].includes(strategy)) throw new Error(`invalid chunk strategy ${strategy}`); Type guard
const isChunkStrategy = (v: unknown): v is 'auto' | 'regex' => v === 'auto' || v === 'regex';
Prevention
- Check qmd collection add --help for accepted enum values before scripting
When it happens
Trigger: Running `qmd collection add . --chunk-strategy ast` or `--chunk-strategy treesitter`; passing an empty string via a script variable.
Common situations: Guessing strategy names from other tools (ast, semantic, ts); older docs or muscle memory from versions before 'auto' existed; quoting mistakes leaving a stray space.
Related errors
- ${name} must be a positive integer
- --timeout must be a non-negative number of minutes (0 = no l
- Collection not found: ${collection}\n${hint}
- No indexed documents found.\nIndex a collection with 'qmd co
- Refusing to initialize a local index in $HOME. The global in
AI-assisted analysis of tobi/qmd@dbfd0b4736 (2026-08-28).
Data as JSON: /api/errors/e8eb69e7134d2141.
Report an issue: GitHub.