{"record":{"id":"18dacdcd0218fe86","repo":"gatsbyjs/gatsby","slug":"plugin-plugin-name-attempted-to-set-request-hea","errorCode":null,"errorMessage":"Plugin ${plugin.name} attempted to set request headers with invalid arguments. See above warnings for more info.","messagePattern":"Plugin (.+?) attempted to set request headers with invalid arguments\\. See above warnings for more info\\.","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"packages/gatsby/src/redux/actions/public.js","lineNumber":1502,"sourceCode":"    typeof headers === `object` && headers !== null && !Array.isArray(headers)\n\n  const noHeaders = !headersIsObject\n  const noDomain = typeof domain !== `string`\n\n  if (noHeaders) {\n    reporter.warn(\n      `Plugin ${plugin.name} called actions.setRequestHeaders with a headers property that isn't an object.`\n    )\n  }\n\n  if (noDomain) {\n    reporter.warn(\n      `Plugin ${plugin.name} called actions.setRequestHeaders with a domain property that isn't a string.`\n    )\n  }\n\n  if (noDomain || noHeaders) {\n    reporter.panic(\n      `Plugin ${plugin.name} attempted to set request headers with invalid arguments. See above warnings for more info.`\n    )\n\n    return null\n  }\n\n  const baseDomain = url.parse(domain)?.hostname\n\n  if (baseDomain) {\n    return {\n      type: `SET_REQUEST_HEADERS`,\n      payload: {\n        domain: baseDomain,\n        headers,\n      },\n    }\n  } else {\n    reporter.panic(","sourceCodeStart":1484,"sourceCodeEnd":1520,"githubUrl":"https://github.com/gatsbyjs/gatsby/blob/8b06340921ffdf23125a365b9c9923690cb62ce6/packages/gatsby/src/redux/actions/public.js#L1484-L1520","documentation":"Thrown by the setRequestHeaders action when either the `headers` argument is not a plain object or the `domain` argument is not a string. The action first emits specific warnings (lines above) describing which argument is bad, then panics. Returns null after panicking.","triggerScenarios":"A call to actions.setRequestHeaders where headers is null/array/primitive (noHeaders true) OR domain is not a string (noDomain true), or both.","commonSituations":"Passing an array instead of an object for headers; forgetting to spread a headers map; passing undefined for domain when configuring per-domain headers dynamically; a config-driven loop that yields undefined for some domains.","solutions":["Pass headers as a plain object (e.g. { 'X-Custom': 'value' }) and domain as a string (e.g. 'example.com').","Guard upstream: if (!domain || typeof headers !== 'object') return before calling the action.","Read the two warnings printed above the panic to see exactly which argument was invalid."],"exampleFix":"// before\nactions.setRequestHeaders({ domain: maybeDomain, headers: headerList })\n// after\nif (typeof maybeDomain === 'string' && headerMap && !Array.isArray(headerMap)) {\n  actions.setRequestHeaders({ domain: maybeDomain, headers: headerMap })\n}","handlingStrategy":"validation","validationCode":"if (typeof domain !== 'string' || !headers || typeof headers !== 'object' || Array.isArray(headers)) {\n  throw new Error('setRequestHeaders needs a string domain and a plain object headers')\n}\nactions.setRequestHeaders({ domain, headers })","typeGuard":"function isHeadersInput(v): v is { domain: string; headers: Record<string,string> } {\n  return v && typeof v.domain === 'string' && !!v.headers && typeof v.headers === 'object' && !Array.isArray(v.headers)\n}","tryCatchPattern":null,"preventionTips":["Always pass headers as a plain object and domain as a string.","Skip the action entirely when inputs are missing rather than letting it panic.","Filter config-driven domain lists to non-empty strings."],"tags":["action","setrequestheaders","validation","headers"],"backgroundTag":null,"analyzedSha":"8b06340921ffdf23125a365b9c9923690cb62ce6","analyzedAt":"2026-08-13T02:36:21.405Z","schemaVersion":2},"datasetVersion":"2026-08-13T04:17:16.726Z"}