{"record":{"id":"5008d5e0a38f36ae","repo":"nodejs/node","slug":"expected-opts-skipheadernames-to-be-an-array-got","errorCode":null,"errorMessage":"expected opts.skipHeaderNames to be an array, got ${typeof skipHeaderNames}","messagePattern":"expected opts\\.skipHeaderNames to be an array, got (.+?)","errorType":"exception","errorClass":"TypeError","httpStatus":null,"severity":"error","filePath":"deps/undici/src/lib/interceptor/deduplicate.js","lineNumber":37,"sourceCode":"    maxBufferSize = 5 * 1024 * 1024\n  } = opts\n\n  if (typeof opts !== 'object' || opts === null) {\n    throw new TypeError(`expected type of opts to be an Object, got ${opts === null ? 'null' : typeof opts}`)\n  }\n\n  if (!Array.isArray(methods)) {\n    throw new TypeError(`expected opts.methods to be an array, got ${typeof methods}`)\n  }\n\n  for (const method of methods) {\n    if (!util.safeHTTPMethods.includes(method)) {\n      throw new TypeError(`expected opts.methods to only contain safe HTTP methods, got ${method}`)\n    }\n  }\n\n  if (!Array.isArray(skipHeaderNames)) {\n    throw new TypeError(`expected opts.skipHeaderNames to be an array, got ${typeof skipHeaderNames}`)\n  }\n\n  if (!Array.isArray(excludeHeaderNames)) {\n    throw new TypeError(`expected opts.excludeHeaderNames to be an array, got ${typeof excludeHeaderNames}`)\n  }\n\n  if (!Number.isFinite(maxBufferSize) || maxBufferSize <= 0) {\n    throw new TypeError(`expected opts.maxBufferSize to be a positive finite number, got ${maxBufferSize}`)\n  }\n\n  // Convert to lowercase Set for case-insensitive header matching\n  const skipHeaderNamesSet = new Set(skipHeaderNames.map(name => name.toLowerCase()))\n\n  // Convert to lowercase Set for case-insensitive header exclusion from deduplication key\n  const excludeHeaderNamesSet = new Set(excludeHeaderNames.map(name => name.toLowerCase()))\n\n  /**\n   * Map of pending requests for deduplication","sourceCodeStart":19,"sourceCodeEnd":55,"githubUrl":"https://github.com/nodejs/node/blob/1b2de5e052fc0fb95fd7fb6846dcec4ade598e9e/deps/undici/src/lib/interceptor/deduplicate.js#L19-L55","documentation":"Thrown by the deduplicate interceptor when `skipHeaderNames` is destructured from `opts` (default `[]`) but is not an Array. `skipHeaderNames` lists request headers whose presence should bypass deduplication — e.g. an `Authorization` header that changes per caller. The factory validates the shape synchronously before building the lowercase Set used for case-insensitive matching.","triggerScenarios":"Passing `skipHeaderNames: 'authorization'` (a bare string) instead of `['authorization']`; passing a comma-separated string like `'authorization,cookie'`; passing an object map of header overrides. The `Array.isArray(skipHeaderNames)` check fails and the interceptor never builds its skip set.","commonSituations":"Reusing a header name string from elsewhere in config; treating the option like Node's `http` header object; migrating from an API that accepted a single string. Because the default is `[]`, the error only surfaces when you explicitly opt into header-skipping.","solutions":["Pass an array of header-name strings: `skipHeaderNames: ['authorization', 'cookie']`.","Names are lowercased internally, so any casing works, but each entry must be a string element of an array.","If sourcing from config, normalize scalars: `const skip = Array.isArray(x) ? x : x ? [x] : []`."],"exampleFix":"// before\ndeduplicate({ skipHeaderNames: 'authorization' })\n\n// after\ndeduplicate({ skipHeaderNames: ['authorization'] })","handlingStrategy":"validation","validationCode":"function toStringArray(v) {\n  if (v == null) return []\n  if (Array.isArray(v)) return v.map(String)\n  if (typeof v === 'string') return v.split(',').map(s => s.trim()).filter(Boolean)\n  throw new TypeError('expected string or array of header names')\n}","typeGuard":"function isHeaderNameArray(v) {\n  return Array.isArray(v) && v.every(x => typeof x === 'string')\n}","tryCatchPattern":null,"preventionTips":["Always pass header-name lists as arrays.","Centralize header-name normalization in one helper."],"tags":["undici","interceptor","deduplicate","headers","validation","config"],"backgroundTag":null,"analyzedSha":"1b2de5e052fc0fb95fd7fb6846dcec4ade598e9e","analyzedAt":"2026-08-13T00:53:24.642Z","schemaVersion":2},"datasetVersion":"2026-08-13T04:17:16.726Z"}