{"record":{"id":"e3f9697b991e86b6","repo":"tobi/qmd","slug":"name-must-be-a-positive-integer","errorCode":null,"errorMessage":"${name} must be a positive integer","messagePattern":"(.+?) must be a positive integer","errorType":"validation","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"src/cli/qmd.ts","lineNumber":2091,"sourceCode":"  }\n  const escaped = skippedFiles.filter(f => f.code === \"OUTSIDE_COLLECTION\").length;\n  const unreadable = skippedFiles.length - escaped;\n  if (escaped) console.warn(`Skipped ${escaped} file(s) outside the collection root`);\n  if (unreadable) console.warn(`Skipped ${unreadable} unreadable file(s)`);\n}\n\nfunction renderProgressBar(percent: number, width: number = 30): string {\n  const filled = Math.round((percent / 100) * width);\n  const empty = width - filled;\n  const bar = \"█\".repeat(filled) + \"░\".repeat(empty);\n  return bar;\n}\n\nfunction parseEmbedBatchOption(name: string, value: unknown): number | undefined {\n  if (value === undefined) return undefined;\n  const parsed = Number(value);\n  if (!Number.isInteger(parsed) || parsed < 1) {\n    throw new Error(`${name} must be a positive integer`);\n  }\n  return parsed;\n}\n\nfunction parseChunkStrategy(value: unknown): ChunkStrategy | undefined {\n  if (value === undefined) return undefined;\n  const s = String(value);\n  if (s === \"auto\" || s === \"regex\") return s;\n  throw new Error(`--chunk-strategy must be \"auto\" or \"regex\" (got \"${s}\")`);\n}\n\n// --timeout for `qmd embed`: a cap on the whole embed session, in minutes. Returns\n// the value in milliseconds, or undefined to use the default. 0 disables the cap.\nfunction parseEmbedTimeoutOption(value: unknown): number | undefined {\n  if (value === undefined) return undefined;\n  const minutes = Number(value);\n  if (!Number.isFinite(minutes) || minutes < 0) {\n    throw new Error(`--timeout must be a non-negative number of minutes (0 = no limit)`);","sourceCodeStart":2073,"sourceCodeEnd":2109,"githubUrl":"https://github.com/tobi/qmd/blob/dbfd0b4736aeaf761d1a16ca8e424f071df8feb9/src/cli/qmd.ts#L2073-L2109","documentation":"Thrown by parseEmbedBatchOption when an embed batch-size option (e.g. --batch-size) is provided but is not a positive integer. Values like 0, -1, 2.5, or 'abc' are rejected.","triggerScenarios":"Running `qmd embed --batch-size 0`, `--batch-size 50.5`, or a non-numeric value; passing the option through a script with an unset variable defaulting to empty string.","commonSituations":"Shell scripts passing empty or fractional variables; copy-pasting flags from docs with placeholder values; using 0 intending 'unlimited'.","solutions":["Pass a whole number >= 1, e.g. `qmd embed --batch-size 32`","Omit the flag entirely to use the default","If 'no limit' was intended, drop the option or use --timeout 0 (which is the capped option that supports 0)"],"exampleFix":"# before\nqmd embed --batch-size 0\n# after\nqmd embed --batch-size 32","handlingStrategy":"type-guard","validationCode":"const n = Number(v);\nif (!Number.isInteger(n) || n < 1) throw new RangeError('--batch-size must be a positive integer');","typeGuard":"const isPositiveInt = (v: unknown): v is number => typeof v === 'number' && Number.isInteger(v) && v >= 1;","tryCatchPattern":null,"preventionTips":["Default script options: \"${BATCH:-32}\"","Remember 0 is not a valid batch size; omit the flag for defaults"],"tags":["cli","embed","option-validation"],"backgroundTag":"invalid-cli-argument","analyzedSha":"dbfd0b4736aeaf761d1a16ca8e424f071df8feb9","analyzedAt":"2026-08-28T18:07:46.628Z","schemaVersion":2},"datasetVersion":"2026-08-28T21:17:43.275Z"}