{"record":{"id":"e37d29b0249a7f75","repo":"nodejs/node","slug":"expected-opts-excludeheadernames-to-be-an-array-g","errorCode":null,"errorMessage":"expected opts.excludeHeaderNames to be an array, got ${typeof excludeHeaderNames}","messagePattern":"expected opts\\.excludeHeaderNames to be an array, got (.+?)","errorType":"exception","errorClass":"TypeError","httpStatus":null,"severity":"error","filePath":"deps/undici/src/lib/interceptor/deduplicate.js","lineNumber":41,"sourceCode":"    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\n   * @type {Map<string, DeduplicationHandler>}\n   */\n  const pendingRequests = new Map()\n","sourceCodeStart":23,"sourceCodeEnd":59,"githubUrl":"https://github.com/nodejs/node/blob/1b2de5e052fc0fb95fd7fb6846dcec4ade598e9e/deps/undici/src/lib/interceptor/deduplicate.js#L23-L59","documentation":"Thrown by the deduplicate interceptor when `excludeHeaderNames` is destructured from `opts` (default `[]`) but is not an Array. Unlike `skipHeaderNames` (which skips deduplication entirely when present), `excludeHeaderNames` excludes the named headers from the deduplication *key* so that requests differing only in those headers are still coalesced. The factory lowercases the entries into a Set at construction time.","triggerScenarios":"Passing `excludeHeaderNames: 'x-request-id'` as a string; passing a Set or object instead of an Array; passing a delimited string. The `Array.isArray(excludeHeaderNames)` guard fails before the Set is built.","commonSituations":"Confusing `excludeHeaderNames` (header omitted from the key) with `skipHeaderNames` (header disables dedup); passing a single header as a bare string; reusing a config value typed as a string. Often appears together with errors 300-302 from one malformed options object.","solutions":["Pass an array of header-name strings: `excludeHeaderNames: ['x-request-id', 'trace-id']`.","Confirm you actually want key-exclusion semantics vs. full skip — use `skipHeaderNames` if the header should bypass deduplication entirely.","Normalize single-string config values into arrays before passing."],"exampleFix":"// before\ndeduplicate({ excludeHeaderNames: 'x-request-id' })\n\n// after\ndeduplicate({ excludeHeaderNames: ['x-request-id'] })","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":["Distinguish excludeHeaderNames (key omission) from skipHeaderNames (full bypass).","Pass header-name lists as arrays."],"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"}