{"record":{"id":"43f56ba1f3c26dd3","repo":"sickn33/agentic-awesome-skills","slug":"pw-extra-headers-must-be-a-json-object-ignoring","errorCode":null,"errorMessage":"PW_EXTRA_HEADERS must be a JSON object, ignoring...","messagePattern":"PW_EXTRA_HEADERS must be a JSON object, ignoring\\.\\.\\.","errorType":"console","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"skills/playwright-skill/lib/helpers.js","lineNumber":29,"sourceCode":" * Single header format takes precedence if both are set.\n * @returns {Object|null} Headers object or null if none configured\n */\nfunction getExtraHeadersFromEnv() {\n  const headerName = process.env.PW_HEADER_NAME;\n  const headerValue = process.env.PW_HEADER_VALUE;\n\n  if (headerName && headerValue) {\n    return { [headerName]: headerValue };\n  }\n\n  const headersJson = process.env.PW_EXTRA_HEADERS;\n  if (headersJson) {\n    try {\n      const parsed = JSON.parse(headersJson);\n      if (typeof parsed === 'object' && parsed !== null && !Array.isArray(parsed)) {\n        return parsed;\n      }\n      console.warn('PW_EXTRA_HEADERS must be a JSON object, ignoring...');\n    } catch (e) {\n      console.warn('Failed to parse PW_EXTRA_HEADERS as JSON:', e.message);\n    }\n  }\n\n  return null;\n}\n\n/**\n * Launch browser with standard configuration\n * @param {string} browserType - 'chromium', 'firefox', or 'webkit'\n * @param {Object} options - Additional launch options\n */\nasync function launchBrowser(browserType = 'chromium', options = {}) {\n  const defaultOptions = {\n    headless: process.env.HEADLESS !== 'false',\n    slowMo: process.env.SLOW_MO ? parseInt(process.env.SLOW_MO) : 0,\n    args: ['--no-sandbox', '--disable-setuid-sandbox']","sourceCodeStart":11,"sourceCodeEnd":47,"githubUrl":"https://github.com/sickn33/agentic-awesome-skills/blob/58d857988fcfac6986206bca2b2fe223aa437e4b/skills/playwright-skill/lib/helpers.js#L11-L47","documentation":"getExtraHeadersFromEnv read PW_EXTRA_HEADERS and JSON.parse succeeded, but the parsed value was not a plain object — it was an array, a string, a number, or null. The helper warns and returns null, so Playwright requests proceed without the intended extra headers. It is a configuration warning, not a crash: the run continues, silently missing headers such as Authorization.","triggerScenarios":"Setting PW_EXTRA_HEADERS to a JSON array like '[\"Authorization: Bearer x\"]', a bare quoted string, a number, or 'null' — all valid JSON, none an object.","commonSituations":"Copying a curl-style header list into the variable; YAML or docker-compose interpolation leaving the value a string; CI templates injecting 'null' for an unset secret; misunderstanding that the variable expects a name-to-value object.","solutions":["Set the variable to a flat JSON object of header names to string values","Check quoting in your shell or YAML so the value arrives as one JSON object string"],"exampleFix":"# before\nexport PW_EXTRA_HEADERS='[\"Authorization: Bearer x\"]'\n\n# after\nexport PW_EXTRA_HEADERS='{\"Authorization\":\"Bearer x\",\"X-Custom\":\"value\"}'","handlingStrategy":"type-guard","validationCode":"const raw = process.env.PW_EXTRA_HEADERS;\nif (raw) {\n  const v = JSON.parse(raw);\n  if (typeof v !== 'object' || v === null || Array.isArray(v)) throw new Error('PW_EXTRA_HEADERS must be a JSON object');\n}","typeGuard":"function isHeaderObject(v: unknown): v is Record<string, string> {\n  return typeof v === 'object' && v !== null && !Array.isArray(v) &&\n    Object.values(v).every(x => typeof x === 'string');\n}","tryCatchPattern":null,"preventionTips":["Fail fast at startup on invalid config instead of silently continuing without headers","Add an env-var schema check to the deploy pipeline"],"tags":["playwright","environment-variable","json","configuration","headers"],"backgroundTag":"invalid-env-var-json-config","analyzedSha":"58d857988fcfac6986206bca2b2fe223aa437e4b","analyzedAt":"2026-08-26T11:55:59.350Z","schemaVersion":2},"datasetVersion":"2026-08-26T14:46:13.012Z"}