{"record":{"id":"ada1d8053b7e7d6c","repo":"nodejs/node","slug":"invalid-dualstack-must-be-a-boolean","errorCode":null,"errorMessage":"Invalid dualStack. Must be a boolean","messagePattern":"Invalid dualStack\\. Must be a boolean","errorType":"exception","errorClass":"InvalidArgumentError","httpStatus":null,"severity":"error","filePath":"deps/undici/src/lib/interceptor/dns.js","lineNumber":488,"sourceCode":"  ) {\n    throw new InvalidArgumentError(\n      'Invalid maxItems. Must be a positive number and greater than zero'\n    )\n  }\n\n  if (\n    interceptorOpts?.affinity != null &&\n    interceptorOpts?.affinity !== 4 &&\n    interceptorOpts?.affinity !== 6\n  ) {\n    throw new InvalidArgumentError('Invalid affinity. Must be either 4 or 6')\n  }\n\n  if (\n    interceptorOpts?.dualStack != null &&\n    typeof interceptorOpts?.dualStack !== 'boolean'\n  ) {\n    throw new InvalidArgumentError('Invalid dualStack. Must be a boolean')\n  }\n\n  if (\n    interceptorOpts?.lookup != null &&\n    typeof interceptorOpts?.lookup !== 'function'\n  ) {\n    throw new InvalidArgumentError('Invalid lookup. Must be a function')\n  }\n\n  if (\n    interceptorOpts?.pick != null &&\n    typeof interceptorOpts?.pick !== 'function'\n  ) {\n    throw new InvalidArgumentError('Invalid pick. Must be a function')\n  }\n\n  if (\n    interceptorOpts?.storage != null &&","sourceCodeStart":470,"sourceCodeEnd":506,"githubUrl":"https://github.com/nodejs/node/blob/1b2de5e052fc0fb95fd7fb6846dcec4ade598e9e/deps/undici/src/lib/interceptor/dns.js#L470-L506","documentation":"Thrown by the DNS interceptor factory (`InvalidArgumentError`, code `UND_ERR_INVALID_ARG`) when `dualStack` is provided and is not a boolean. `dualStack` (default `true`) controls whether the interceptor issues parallel IPv4+IPv6 connect attempts (Happy Eyeballs) and races them; it must be a strict boolean because it gates branch logic that compares against `true`/`false`.","triggerScenarios":"Passing `dualStack: 'true'` (string), `dualStack: 1`, `dualStack: 'yes'`, or `dualStack: undefined`-coerced-from-config. The guard is `dualStack != null && typeof !== 'boolean'`. Note `0`/`1` are numbers and fail.","commonSituations":"Reading the flag from an env var (`process.env.DUAL_STACK` is always a string); JSON config that serialized a truthy string; passing an integer from a checkbox. The default `true` masks the requirement until you try to force single-stack.","solutions":["Pass a literal boolean: `dualStack: false`.","Coerce env strings explicitly: `dualStack: process.env.DUAL_STACK !== 'false'`.","If you only need family preference, leave `dualStack: true` and use `affinity` instead."],"exampleFix":"// before\ndns({ dualStack: process.env.DUAL_STACK })   // string 'false'\ndns({ dualStack: 'true' })\n\n// after\ndns({ dualStack: false })\ndns({ dualStack: process.env.DUAL_STACK !== 'false' })","handlingStrategy":"validation","validationCode":"function toBool(v, fallback = true) {\n  if (v == null) return fallback\n  if (typeof v === 'boolean') return v\n  if (typeof v === 'string') return v.toLowerCase() !== 'false' && v !== '0'\n  return Boolean(v)\n}","typeGuard":"function isBoolean(v) {\n  return typeof v === 'boolean'\n}","tryCatchPattern":null,"preventionTips":["Coerce env booleans explicitly: `envVal !== 'false'`.","Never rely on truthy 0/1 for dualStack."],"tags":["undici","interceptor","dns","dualstack","happy-eyeballs","validation","config"],"backgroundTag":null,"analyzedSha":"1b2de5e052fc0fb95fd7fb6846dcec4ade598e9e","analyzedAt":"2026-08-13T00:53:24.642Z","schemaVersion":2},"datasetVersion":"2026-08-13T04:17:16.726Z"}