{"record":{"id":"b8cb705101ebf73c","repo":"CherryHQ/cherry-studio","slug":"invalid-header-expected-name-value-value","errorCode":null,"errorMessage":"Invalid --header (expected \"Name: value\"): ${value}","messagePattern":"Invalid --header \\(expected \"Name: value\"\\): (.+?)","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"scripts/capture-image-response.ts","lineNumber":51,"sourceCode":"    const flag = argv[i]\n    const value = argv[++i]\n    if (value === undefined) throw new Error(`Missing value for ${flag}`)\n    switch (flag) {\n      case '--url':\n        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'","sourceCodeStart":33,"sourceCodeEnd":69,"githubUrl":"https://github.com/CherryHQ/cherry-studio/blob/726446b54cd69ffe51a276638672f6d95ca0768c/scripts/capture-image-response.ts#L33-L69","documentation":"Thrown by scripts/capture-image-response.ts when a --header value does not contain a colon (':') separator. Headers must be in 'Name: value' form so the parser can split on the first colon into header name and value. Without a colon the split is impossible, so the script rejects the input rather than guessing.","triggerScenarios":"Passing --header \"Authorization Bearer xxx\" (space instead of colon), --header \"Authorization\" (value missing), or a header where the colon was stripped by shell interpolation. The check is value.indexOf(':') === -1.","commonSituations":"Typing a header from memory with a space instead of a colon; copy-pasting a header that used an equals sign (Authorization=Bearer ...); a shell variable expansion that swallowed the colon; using cURL-style '-H Name: value' but forgetting the colon.","solutions":["Format every --header as \"Name: value\" with a colon, e.g. --header \"Authorization: Bearer $KEY\".","For headers whose value contains a colon (e.g. URLs, timestamps), note the split uses the FIRST colon — that is fine for standard names like 'Content-Type'.","Quote the entire header argument so the shell preserves the colon and spaces.","Double-check each --header token in your command for a colon before running."],"exampleFix":"# before\nnpx tsx scripts/capture-image-response.ts --header \"Authorization Bearer $KEY\"\n\n# after\nnpx tsx scripts/capture-image-response.ts --header \"Authorization: Bearer $KEY\"","handlingStrategy":"validation","validationCode":"// Validate header shape before building the command\nconst headerPattern = /^[^:]+\\s*:\\s*.+$/\nif (!headerPattern.test(headerString)) {\n  throw new Error(`Header must be 'Name: value', got: ${headerString}`)\n}","typeGuard":"const isValidHeader = (h: string): boolean => h.indexOf(':') !== -1","tryCatchPattern":null,"preventionTips":["Always use a colon in --header values: \"Name: value\".","Quote the full header so the shell preserves colon and spaces.","For values containing colons, remember the split uses the first colon — safe for standard names."],"tags":["cli","script","args","validation","http-headers"],"backgroundTag":null,"analyzedSha":"726446b54cd69ffe51a276638672f6d95ca0768c","analyzedAt":"2026-08-12T17:30:37.448Z","schemaVersion":2},"datasetVersion":"2026-08-12T18:17:37.767Z"}