{"record":{"id":"10f805136e1332ff","repo":"garrytan/gstack","slug":"unknown-pdf-flag-a","errorCode":null,"errorMessage":"Unknown pdf flag: ${a}","messagePattern":"Unknown pdf flag: (.+?)","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"browse/src/meta-commands.ts","lineNumber":117,"sourceCode":"    const a = args[i];\n    if (a === '--format') { result.format = requireValue(args, ++i, 'format'); }\n    else if (a === '--page-size') { result.format = requireValue(args, ++i, 'page-size'); }\n    else if (a === '--width') { result.width = requireValue(args, ++i, 'width'); }\n    else if (a === '--height') { result.height = requireValue(args, ++i, 'height'); }\n    else if (a === '--margins') { margins = requireValue(args, ++i, 'margins'); }\n    else if (a === '--margin-top') { result.marginTop = requireValue(args, ++i, 'margin-top'); }\n    else if (a === '--margin-right') { result.marginRight = requireValue(args, ++i, 'margin-right'); }\n    else if (a === '--margin-bottom') { result.marginBottom = requireValue(args, ++i, 'margin-bottom'); }\n    else if (a === '--margin-left') { result.marginLeft = requireValue(args, ++i, 'margin-left'); }\n    else if (a === '--header-template') { result.headerTemplate = requireValue(args, ++i, 'header-template'); }\n    else if (a === '--footer-template') { result.footerTemplate = requireValue(args, ++i, 'footer-template'); }\n    else if (a === '--page-numbers') { result.pageNumbers = true; }\n    else if (a === '--tagged') { result.tagged = true; }\n    else if (a === '--outline') { result.outline = true; }\n    else if (a === '--print-background') { result.printBackground = true; }\n    else if (a === '--prefer-css-page-size') { result.preferCSSPageSize = true; }\n    else if (a === '--toc') { result.toc = true; }\n    else if (a.startsWith('--')) { throw new Error(`Unknown pdf flag: ${a}`); }\n    else { positional.push(a); }\n  }\n\n  if (positional.length > 0) result.output = positional[0];\n\n  if (margins !== undefined) {\n    if (result.marginTop || result.marginRight || result.marginBottom || result.marginLeft) {\n      throw new Error('pdf: --margins is mutex with --margin-top/--margin-right/--margin-bottom/--margin-left');\n    }\n    result.marginTop = result.marginRight = result.marginBottom = result.marginLeft = margins;\n  }\n\n  if (result.format && (result.width || result.height)) {\n    throw new Error('pdf: --format is mutex with --width/--height');\n  }\n  if (result.pageNumbers && result.footerTemplate) {\n    throw new Error('pdf: --page-numbers is mutex with --footer-template (page-numbers writes the footer itself)');\n  }","sourceCodeStart":99,"sourceCodeEnd":135,"githubUrl":"https://github.com/garrytan/gstack/blob/94993f74012782fd94416dd44b8314f6363a13a4/browse/src/meta-commands.ts#L99-L135","documentation":"Thrown by parsePdfArgs() when a token starts with '--' but does not match any recognized PDF flag. The parser checks against a fixed set of known flags (--margin-top, --format, --width, etc.) and falls through to this error for any unrecognized double-dash token.","triggerScenarios":"Passing any unrecognized '--flag' to the pdf command, e.g., '--paper-size', '--orientation', or a typo like '--formatt'.","commonSituations":"Typo in a flag name, using a flag from a different command, or passing a flag from a newer/older version of the API.","solutions":["Check the flag spelling against the known set: --output, --format, --width, --height, --margins, --margin-top/right/bottom/left, --header-template, --footer-template, --page-numbers, --tagged, --outline, --print-background, --prefer-css-page-size, --toc","If the flag is valid in a different version, check for version mismatches","Remove the unrecognized flag or replace it with the correct equivalent"],"exampleFix":"# before\n$B pdf --formatt A4 page.pdf\n\n# after\n$B pdf --format A4 page.pdf","handlingStrategy":"validation","validationCode":"const KNOWN_PDF_FLAGS = new Set([\n  '--output','--format','--width','--height','--margins',\n  '--margin-top','--margin-right','--margin-bottom','--margin-left',\n  '--header-template','--footer-template','--page-numbers',\n  '--tagged','--outline','--print-background','--prefer-css-page-size','--toc','--from-file'\n]);\nfor (const a of args) {\n  if (a.startsWith('--') && !KNOWN_PDF_FLAGS.has(a)) {\n    throw new Error(`Unknown pdf flag: ${a}`);\n  }\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Maintain a whitelist of valid PDF flags in your calling code","Validate flags before passing them to the pdf command","Check for version updates when new flags are added to the API"],"tags":["pdf","cli","argument-parsing"],"backgroundTag":null,"analyzedSha":"94993f74012782fd94416dd44b8314f6363a13a4","analyzedAt":"2026-08-12T04:06:23.140Z","schemaVersion":2},"datasetVersion":"2026-08-12T13:17:24.610Z"}