{"record":{"id":"dd71df38cccb835d","repo":"denoland/deno","slug":"err-invalid-arg-type-dd71df","errorCode":"ERR_INVALID_ARG_TYPE","errorMessage":"The \"options\" argument must be of type object or integer. Received ${options}","messagePattern":"The \"options\" argument must be of type object or integer\\. Received (.+?)","errorType":"error_code","errorClass":"TypeError","httpStatus":null,"severity":"error","filePath":"ext/node/polyfills/internal/dns/promises.ts","lineNumber":192,"sourceCode":"function lookup(\n  hostname: string,\n  options: unknown,\n): Promise<void | LookupAddress | LookupAddress[]> {\n  let hints = 0;\n  let family = 0;\n  let all = false;\n  let dnsOrder = getDefaultDnsOrder();\n\n  // Parse arguments\n  if (hostname) {\n    validateString(hostname, \"hostname\");\n  }\n\n  if (isFamily(options)) {\n    validateOneOf(options, \"family\", validFamilies);\n    family = options;\n  } else if (!isLookupOptions(options)) {\n    throw new ERR_INVALID_ARG_TYPE(\"options\", [\"integer\", \"object\"], options);\n  } else {\n    if (options?.hints != null) {\n      validateNumber(options.hints, \"options.hints\");\n      hints = options.hints >>> 0;\n      validateHints(hints);\n    }\n\n    if (options?.family != null) {\n      // Accept both numeric (0, 4, 6) and string ('IPv4', 'IPv6') family values\n      // to match Node.js behavior\n      switch (options.family) {\n        case \"IPv4\":\n          family = 4;\n          break;\n        case \"IPv6\":\n          family = 6;\n          break;\n        default:","sourceCodeStart":174,"sourceCodeEnd":210,"githubUrl":"https://github.com/denoland/deno/blob/a961cdec3b1948844414ebeecc697dcad76df2d1/ext/node/polyfills/internal/dns/promises.ts#L174-L210","documentation":"dns.promises.lookup() accepts options as either an integer IP family or an options object (hints, family, all, order, ...). The polyfill tests options with isFamily() (integer, then validated against validFamilies) and isLookupOptions() (options-object shape); anything else - strings, booleans, arrays, null - throws ERR_INVALID_ARG_TYPE listing ['integer', 'object'].","triggerScenarios":"dnsPromises.lookup('example.com', '4') or 'ipv6' (family as a string); lookup(host, ['A']); lookup(host, true); passing a parsed URL object as options.","commonSituations":"Config files that store family as text; env-var-driven options coerced to strings; code copied from dns.resolve()-style APIs where the second argument is a record-type string.","solutions":["Pass the object form: dnsPromises.lookup(host, { family: 4 }).","Coerce config values once at startup: family = Number(family), then wrap into the options object.","Reject non-integer/non-object option values at the boundary with an isFamilyOrOptions guard."],"exampleFix":"// before\ndnsPromises.lookup(host, '4'); // family as string\n\n// after\ndnsPromises.lookup(host, { family: 4 });\n// or: dnsPromises.lookup(host, 4);","handlingStrategy":"validation","validationCode":"function normalizeLookupOptions(o) {\n  if (o === undefined) return undefined;\n  if (Number.isInteger(o) && [0, 4, 6].includes(o)) return o;\n  if (typeof o === 'object' && o !== null && !Array.isArray(o)) return o;\n  throw new TypeError('options must be an integer family or an options object');\n}\nawait dns.promises.lookup(host, normalizeLookupOptions(opts));","typeGuard":"const isFamilyOrOptions = (o) =>\n  (Number.isInteger(o) && [0, 4, 6].includes(o)) ||\n  (typeof o === 'object' && o !== null && !Array.isArray(o));","tryCatchPattern":"try {\n  await dnsPromises.lookup(host, opts);\n} catch (err) {\n  if (err?.code === 'ERR_INVALID_ARG_TYPE' && err.message.includes('options')) {\n    return dnsPromises.lookup(host, {});\n  }\n  throw err;\n}","preventionTips":["Never pass family as a string - wrap it as { family: 4 }.","Validate config-driven options once at startup.","Remember arrays and null are not valid lookup options."],"tags":["dns","lookup","options","argument-type","node-compat"],"backgroundTag":"dns-lookup-options","analyzedSha":"a961cdec3b1948844414ebeecc697dcad76df2d1","analyzedAt":"2026-08-20T13:07:44.778Z","contentChangedAt":"2026-08-20T13:07:44.778Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}