{"record":{"id":"f0800c8bc015fcb2","repo":"garrytan/gstack","slug":"usage-browse-header-name-value","errorCode":null,"errorMessage":"Usage: browse header <name>:<value>","messagePattern":"Usage: browse header <name>:<value>","errorType":"validation","errorClass":"Error","httpStatus":null,"severity":"warning","filePath":"browse/src/write-commands.ts","lineNumber":573,"sourceCode":"    case 'cookie': {\n      const cookieStr = args[0];\n      if (!cookieStr || !cookieStr.includes('=')) throw new Error('Usage: browse cookie <name>=<value>');\n      const eq = cookieStr.indexOf('=');\n      const name = cookieStr.slice(0, eq);\n      const value = cookieStr.slice(eq + 1);\n      const url = new URL(page.url());\n      await page.context().addCookies([{\n        name,\n        value,\n        domain: url.hostname,\n        path: '/',\n      }]);\n      return `Cookie set: ${name}=****`;\n    }\n\n    case 'header': {\n      const headerStr = args[0];\n      if (!headerStr || !headerStr.includes(':')) throw new Error('Usage: browse header <name>:<value>');\n      const sep = headerStr.indexOf(':');\n      const name = headerStr.slice(0, sep).trim();\n      const value = headerStr.slice(sep + 1).trim();\n      await bm.setExtraHeader(name, value);\n      const sensitiveHeaders = ['authorization', 'cookie', 'set-cookie', 'x-api-key', 'x-auth-token'];\n      const redactedValue = sensitiveHeaders.includes(name.toLowerCase()) ? '****' : value;\n      return `Header set: ${name}: ${redactedValue}`;\n    }\n\n    case 'useragent': {\n      const ua = args.join(' ');\n      if (!ua) throw new Error('Usage: browse useragent <string>');\n      bm.setUserAgent(ua);\n      const error = await bm.recreateContext();\n      if (error) {\n        return `User agent set to \"${ua}\" but: ${error}`;\n      }\n      return `User agent set: ${ua}`;","sourceCodeStart":555,"sourceCodeEnd":591,"githubUrl":"https://github.com/garrytan/gstack/blob/94993f74012782fd94416dd44b8314f6363a13a4/browse/src/write-commands.ts#L555-L591","documentation":"Thrown by `browse header` when the first argument is missing or does not contain a `:` character. The command splits on the first `:` to derive header name and value; without a colon it cannot determine the boundary and rejects the input. This is the header counterpart to the cookie command's `=` requirement.","triggerScenarios":"Calling `browse header` with no args; `browse header X-Custom` (value omitted); `browse header X-Custom=foo` (used `=` instead of `:`); a value that legitimately contains no colon because the user passed only the name.","commonSituations":"User conflates header (`:`) and cookie (`=`) syntax; an agent copies a fetch options object (`{ 'X-Custom': 'foo' }`) and emits `X-Custom foo` losing the separator; setting a header whose value contains a URL (`Referer: https://...`) works because only the first `:` is the split point — the user incorrectly assumes the URL's `://` breaks parsing and pre-trims.","solutions":["Provide the token as `name:value`: `browse header X-Custom:foo`.","Only the FIRST colon is the separator, so values containing colons (URLs, times) are fine: `browse header Referer:https://example.com`.","If you meant to set a cookie, use `browse cookie name=value`.","Sensitive header names (authorization, cookie, set-cookie, x-api-key, x-auth-token) are redacted to `****` in the success message — the value is still applied, only the echo is masked."],"exampleFix":"// before\nawait runBrowseCommand(['header', 'X-Custom=foo']);\n\n// after\nawait runBrowseCommand(['header', 'X-Custom:foo']);","handlingStrategy":"validation","validationCode":"function parseHeaderToken(token: string): { name: string; value: string } {\n  if (!token || !token.includes(':')) {\n    throw new Error('header token must be name:value');\n  }\n  const sep = token.indexOf(':');\n  return { name: token.slice(0, sep).trim(), value: token.slice(sep + 1).trim() };\n}","typeGuard":"function isHeaderToken(s: string): boolean {\n  return typeof s === 'string' && s.includes(':');\n}","tryCatchPattern":null,"preventionTips":["Use ':' as the separator for headers (the first ':' is the split point, so URL values work).","Do not confuse with the cookie command which uses '='.","Sensitive header names are redacted in the success echo but still applied."],"tags":["cli-usage","headers","argument-validation","browse-command"],"backgroundTag":null,"analyzedSha":"94993f74012782fd94416dd44b8314f6363a13a4","analyzedAt":"2026-08-12T04:06:23.140Z","schemaVersion":2},"datasetVersion":"2026-08-12T13:17:24.610Z"}