{"record":{"id":"48bd3b34d860cf87","repo":"CherryHQ/cherry-studio","slug":"unknown-flag-flag","errorCode":null,"errorMessage":"Unknown flag: ${flag}","messagePattern":"Unknown flag: (.+?)","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"scripts/capture-image-response.ts","lineNumber":56,"sourceCode":"        args.url = value\n        break\n      case '--body':\n        args.body = value\n        break\n      case '--method':\n        args.method = value.toUpperCase()\n        break\n      case '--out':\n        args.out = value\n        break\n      case '--header': {\n        const idx = value.indexOf(':')\n        if (idx === -1) throw new Error(`Invalid --header (expected \"Name: value\"): ${value}`)\n        args.headers[value.slice(0, idx).trim()] = value.slice(idx + 1).trim()\n        break\n      }\n      default:\n        throw new Error(`Unknown flag: ${flag}`)\n    }\n  }\n  return args\n}\n\nasync function main() {\n  const args = parseArgs(process.argv.slice(2))\n  if (!args.url) throw new Error('--url is required')\n\n  const method = args.method ?? (args.body ? 'POST' : 'GET')\n  const headers: Record<string, string> = { Accept: 'application/json', ...args.headers }\n  if (args.body && !Object.keys(headers).some((h) => h.toLowerCase() === 'content-type')) {\n    headers['Content-Type'] = 'application/json'\n  }\n\n  // Show the request WITHOUT auth values.\n  const safeHeaders = Object.fromEntries(\n    Object.entries(headers).map(([k, v]) => [k, /authorization|api-key|x-api-key|token/i.test(k) ? '<redacted>' : v])","sourceCodeStart":38,"sourceCodeEnd":74,"githubUrl":"https://github.com/CherryHQ/cherry-studio/blob/726446b54cd69ffe51a276638672f6d95ca0768c/scripts/capture-image-response.ts#L38-L74","documentation":"Thrown by scripts/capture-image-response.ts when the argument parser encounters a flag token it does not recognize. The switch statement handles only --url, --body, --method, --out, and --header; any other token starting with the flag pattern (or any token in flag position) hits the default case and throws.","triggerScenarios":"Passing a typo'd or unsupported flag such as --URL (wrong case), --ur1, --auth, --api-key, -H, or --output (the script uses --out). Any flag not in the supported set triggers this.","commonSituations":"Case-sensitivity mistake (--URL vs --url); using a cURL-style shorthand (-H, -X) the script does not accept; guessing a flag name from another tool; copy-pasting flags from documentation for a different script.","solutions":["Use only the supported flags: --url (required), --body, --method, --out, --header (repeatable).","Check spelling and case — flags are lowercase and exact (--url, not --URL or --Url).","Use --out (not --output) and --method (not -X) — this script does not implement cURL shorthands.","Re-read the usage comment at the top of scripts/capture-image-response.ts for the canonical invocation."],"exampleFix":"# before\nnpx tsx scripts/capture-image-response.ts --URL 'https://...' --output resp.json\n\n# after\nnpx tsx scripts/capture-image-response.ts --url 'https://...' --out resp.json","handlingStrategy":"validation","validationCode":"const KNOWN_FLAGS = new Set(['--url', '--body', '--method', '--out', '--header'])\nfor (const tok of argv.filter((t) => t.startsWith('--'))) {\n  if (!KNOWN_FLAGS.has(tok)) throw new Error(`Unknown flag: ${tok}`)\n}","typeGuard":"const KNOWN = new Set(['--url','--body','--method','--out','--header'])\nconst isKnownFlag = (f: string): boolean => KNOWN.has(f)","tryCatchPattern":null,"preventionTips":["Use only --url, --body, --method, --out, --header (exact lowercase).","Avoid cURL-style shorthands (-H, -X) — this script does not accept them.","Re-check the usage comment at the top of the script for the canonical flags."],"tags":["cli","script","args","validation"],"backgroundTag":null,"analyzedSha":"726446b54cd69ffe51a276638672f6d95ca0768c","analyzedAt":"2026-08-12T17:30:37.448Z","schemaVersion":2},"datasetVersion":"2026-08-12T23:17:12.415Z"}