{"record":{"id":"4257552886298d69","repo":"denoland/deno","slug":"err-invalid-arg-value-425755","errorCode":"ERR_INVALID_ARG_VALUE","errorMessage":"The argument 'hints' is invalid. Received ${hints}","messagePattern":"The argument 'hints' is invalid\\. Received (.+?)","errorType":"validation","errorClass":"NodeTypeError","httpStatus":null,"severity":"error","filePath":"ext/node/polyfills/internal/dns/utils.ts","lineNumber":435,"sourceCode":"    }\n\n    this._handle.setLocalAddress(ipv4, ipv6);\n  }\n}\n\nlet defaultResolver = new Resolver();\n\nfunction getDefaultResolver(): Resolver {\n  return defaultResolver;\n}\n\nfunction setDefaultResolver<T extends Resolver>(resolver: T) {\n  defaultResolver = resolver;\n}\n\nfunction validateHints(hints: number) {\n  if ((hints & ~(AI_ADDRCONFIG | AI_ALL | AI_V4MAPPED)) !== 0) {\n    throw new ERR_INVALID_ARG_VALUE(\"hints\", hints, \"is invalid\");\n  }\n}\n\nlet dnsOrder: string | undefined;\n\nfunction ensureDnsOrder(): string {\n  if (dnsOrder === undefined) {\n    dnsOrder = getOptionValue(\"--dns-result-order\") || \"ipv4first\";\n  }\n  return dnsOrder;\n}\n\nfunction getDefaultDnsOrder(): string {\n  return ensureDnsOrder();\n}\n\nconst validDnsOrders = [\"verbatim\", \"ipv4first\", \"ipv6first\"];\n","sourceCodeStart":417,"sourceCodeEnd":453,"githubUrl":"https://github.com/denoland/deno/blob/9ad36f7a2cce60488e6ec52283efb32efddaf93a/ext/node/polyfills/internal/dns/utils.ts#L417-L453","documentation":"dns.lookup()'s hints bitmask may only combine dns.constants.AI_ADDRCONFIG, AI_ALL and AI_V4MAPPED - validateHints() rejects any value with other bits set (hints & ~mask !== 0) with ERR_INVALID_ARG_VALUE. This mirrors Node: other AI_* flags (like AI_NUMERICHOST) are not accepted as lookup hints here.","triggerScenarios":"lookup(host, { hints: 0xff }); hints: -1; OR-ing every dns.constants.AI_* flag together; numeric hint values copied from another platform's headers.","commonSituations":"Developers combining all AI_ constants 'to be safe'; porting C getaddrinfo code with raw flag numbers; config fields that let users pass arbitrary integers as hints.","solutions":["Build hints only from the three allowed constants: hints: AI_ADDRCONFIG | AI_V4MAPPED.","Omit hints entirely when you do not need them - undefined means 'none'.","Validate user/config-provided hints against the mask before calling lookup."],"exampleFix":"// before\ndns.promises.lookup(host, { hints: 0xff });\n\n// after\nimport { AI_ADDRCONFIG, AI_V4MAPPED } from 'node:dns/constants';\ndns.promises.lookup(host, { hints: AI_ADDRCONFIG | AI_V4MAPPED });","handlingStrategy":"validation","validationCode":"import { AI_ADDRCONFIG, AI_ALL, AI_V4MAPPED } from 'node:dns/constants';\nconst HINTS_MASK = AI_ADDRCONFIG | AI_ALL | AI_V4MAPPED;\n\nfunction validHints(h) {\n  return h === undefined || (Number.isInteger(h) && (h & ~HINTS_MASK) === 0);\n}\nif (!validHints(opts.hints)) {\n  throw new RangeError('hints may only combine AI_ADDRCONFIG, AI_ALL, AI_V4MAPPED');\n}\nawait dns.promises.lookup(host, opts);","typeGuard":"import { AI_ADDRCONFIG, AI_ALL, AI_V4MAPPED } from 'node:dns/constants';\nconst isHintsMask = (h) =>\n  Number.isInteger(h) && (h & ~(AI_ADDRCONFIG | AI_ALL | AI_V4MAPPED)) === 0;","tryCatchPattern":"try {\n  await dnsPromises.lookup(host, { hints });\n} catch (err) {\n  if (err?.code === 'ERR_INVALID_ARG_VALUE' && err.message.includes('hints')) {\n    return dnsPromises.lookup(host, {}); // retry with no hints\n  }\n  throw err;\n}","preventionTips":["Build hints only by OR-ing the three allowed dns.constants flags.","Never hardcode numeric hints from other platforms; omit hints when unsure.","Treat other AI_* flags (AI_NUMERICHOST and friends) as invalid for lookup hints here."],"tags":["dns","lookup","hints","bitmask","argument-validation"],"backgroundTag":"dns-lookup-hints","analyzedSha":"9ad36f7a2cce60488e6ec52283efb32efddaf93a","analyzedAt":"2026-08-20T13:07:44.778Z","contentChangedAt":"2026-08-20T13:07:44.778Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}