{"record":{"id":"47c9ed541b07d0f3","repo":"garrytan/gstack","slug":"raw-must-be-true-or-false","errorCode":null,"errorMessage":"--raw must be true or false","messagePattern":"--raw must be true or false","errorType":"validation","errorClass":"Error","httpStatus":null,"severity":"warning","filePath":"browse/src/read-commands.ts","lineNumber":86,"sourceCode":"  const rest: string[] = [];\n  for (let i = 0; i < args.length; i++) {\n    const a = args[i];\n    if (a === '--out') {\n      if (outPath !== undefined) throw new Error('--out specified more than once');\n      const val = args[i + 1];\n      if (val === undefined || val.startsWith('--')) throw new Error('--out requires a file path');\n      outPath = val;\n      i++;\n    } else if (a.startsWith('--out=')) {\n      if (outPath !== undefined) throw new Error('--out specified more than once');\n      const val = a.slice('--out='.length);\n      if (val === '') throw new Error('--out requires a file path');\n      outPath = val;\n    } else if (a === '--raw') {\n      raw = true;\n    } else if (a.startsWith('--raw=')) {\n      const v = a.slice('--raw='.length).toLowerCase();\n      if (v !== 'true' && v !== 'false') throw new Error('--raw must be true or false');\n      raw = v === 'true';\n    } else {\n      rest.push(a);\n    }\n  }\n  return { outPath, raw, rest };\n}\n\n/**\n * True iff an arg list contains an `--out` flag in any accepted form\n * (`--out <path>` or `--out=<path>`). Used by the write-capability gate to\n * decide whether an otherwise-read command (`js`/`eval`) is actually a write\n * invocation. Mirrors parseOutArgs's `--out` recognition exactly. Never throws —\n * a malformed `--out=` still counts as an out attempt (fail safe: gate it).\n */\nexport function hasOutArg(args: string[]): boolean {\n  return args.some(a => a === '--out' || a.startsWith('--out='));\n}","sourceCodeStart":68,"sourceCodeEnd":104,"githubUrl":"https://github.com/garrytan/gstack/blob/94993f74012782fd94416dd44b8314f6363a13a4/browse/src/read-commands.ts#L68-L104","documentation":"Thrown by parseOutArgs when `--raw=<value>` is supplied with a value other than true or false (case-insensitive). The parser only accepts the two boolean literals; any other string is refused to avoid a silent default.","triggerScenarios":"Passing `--raw=yes`, `--raw=1`, `--raw=on`, `--raw=enable`, or a typo like `--raw=flase`.","commonSituations":"Boolean convention mismatch from other tools (1/0, yes/no, on/off); copy-paste from a config that uses a different boolean dialect; typo in the literal.","solutions":["Use --raw=true or --raw=false (case-insensitive)","Use the bare --raw flag as a shorthand for true","Omit --raw entirely if you want the default (false)","Check for typos in the literal — 'flase', 'ture', 'flase' are common"],"exampleFix":"# before\nbrowse js 'render()' --out=img.png --raw=yes   # throws\n\n# after\nbrowse js 'render()' --out=img.png --raw=true\n# or shorthand\nbrowse js 'render()' --out=img.png --raw","handlingStrategy":"validation","validationCode":"function rawValueIsValid(args: string[]): boolean {\n  return args.every(a => {\n    if (!a.startsWith('--raw=')) return true;\n    const v = a.slice('--raw='.length).toLowerCase();\n    return v === 'true' || v === 'false';\n  });\n}\n\nif (!rawValueIsValid(args)) {\n  throw new Error('--raw must be true or false (case-insensitive)');\n}","typeGuard":"function isBooleanLiteral(s: string): boolean {\n  const v = s.toLowerCase();\n  return v === 'true' || v === 'false';\n}","tryCatchPattern":"try {\n  parseOutArgs(args);\n} catch (e: any) {\n  if (/--raw must be true or false/.test(e.message)) {\n    // normalize: replace bad --raw=X with bare --raw\n    const cleaned = args.filter(a => !a.startsWith('--raw=')).concat(['--raw']);\n    parseOutArgs(cleaned);\n  } else throw e;\n}","preventionTips":["Use the bare --raw flag for true, or --raw=true / --raw=false explicitly","Do not use 1/0, yes/no, on/off — only true/false are accepted","Validate boolean literals in your arg builder before passing them in","Check for typos: 'flase', 'ture' are the common ones"],"tags":["cli","args","invalid-value","raw-flag","boolean"],"backgroundTag":null,"analyzedSha":"94993f74012782fd94416dd44b8314f6363a13a4","analyzedAt":"2026-08-12T04:06:23.140Z","schemaVersion":2},"datasetVersion":"2026-08-12T13:17:24.610Z"}