{"record":{"id":"7387645ea78c9146","repo":"denoland/deno","slug":"invalid-ip-address-addr1","errorCode":null,"errorMessage":"Invalid IP address: ${addr1}","messagePattern":"Invalid IP address: (.+?)","errorType":"validation","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"ext/node/polyfills/internal_binding/cares_wrap.ts","lineNumber":939,"sourceCode":"    if (isIPv4(addr0)) {\n      type0 = 4;\n    } else if (isIPv6(addr0)) {\n      type0 = 6;\n    } else {\n      throw new Error(`Invalid IP address: ${addr0}`);\n    }\n\n    if (addr1 !== undefined) {\n      if (isIPv4(addr1)) {\n        if (type0 === 4) {\n          throw new Error(\"Cannot specify two IPv4 addresses\");\n        }\n      } else if (isIPv6(addr1)) {\n        if (type0 === 6) {\n          throw new Error(\"Cannot specify two IPv6 addresses\");\n        }\n      } else {\n        throw new Error(`Invalid IP address: ${addr1}`);\n      }\n    }\n\n    this.#localAddress = {\n      ipv4: type0 === 4 ? addr0 : addr1,\n      ipv6: type0 === 6 ? addr0 : addr1,\n    };\n  }\n\n  cancel() {\n    for (const req of new SafeSetIterator(this.#pendingQueries)) {\n      req.oncomplete(\"ECANCELLED\", []);\n    }\n    SetPrototypeClear(this.#pendingQueries);\n\n    // Abort in-flight DNS operations so the process can exit.\n    for (const rid of new SafeSetIterator(this.#cancelRids)) {\n      core.tryClose(rid);","sourceCodeStart":921,"sourceCodeEnd":957,"githubUrl":"https://github.com/denoland/deno/blob/a961cdec3b1948844414ebeecc697dcad76df2d1/ext/node/polyfills/internal_binding/cares_wrap.ts#L921-L957","documentation":"The secondary local address (addr1) must also be a valid IPv4 or IPv6 literal. When addr0 was accepted but addr1 fails both isIPv4 and isIPv6, this error is thrown. The stored #localAddress only supports strict IP literals, so anything else (hostnames, empty strings, malformed IPv6) is rejected.","triggerScenarios":"Calling a ChannelWrap lookup with a valid primary address but a malformed secondary address, e.g. localAddresses: ['0.0.0.0', 'localhost'] or a truncated IPv6 like 'fe80::1%'.","commonSituations":"Splitting an 'address:port' or CIDR string that leaves garbage in the second element; env/config where the second address field is empty or contains a zone-indexed IPv6 unsupported by strict parsing.","solutions":["Validate each address with isIPv4/isIPv6 before passing it and fix the malformed one.","Pass undefined instead of an empty/invalid string when no secondary address is needed.","Strip zone indices/whitespace and normalize the address string first."],"exampleFix":"// before\nnew ChannelWrap('0.0.0.0', 'localhost'); // hostname not allowed\n// after\nnew ChannelWrap('0.0.0.0', '::1'); // use an IP literal","handlingStrategy":"validation","validationCode":"for (const a of [addr0, addr1]) {\n  if (a !== undefined && !(isIPv4(a) || isIPv6(a))) {\n    throw new Error(`Not an IP literal: ${a}`);\n  }\n}","typeGuard":"function isStrictIp(a) {\n  return a === undefined || (typeof a === 'string' && (isIPv4(a) || isIPv6(a)));\n}","tryCatchPattern":"try {\n  channel.lookup(req, hostname);\n} catch (err) {\n  if (String(err.message).startsWith('Invalid IP address')) {\n    // unset the offending local address and retry\n  }\n}","preventionTips":["Trim and normalize address strings (strip zone indices, whitespace) before use.","Pass undefined rather than '' or 'localhost' when no secondary address is wanted.","Validate every address field at config parse time."],"tags":["dns","node-compat","validation"],"backgroundTag":"invalid-ip-address","analyzedSha":"a961cdec3b1948844414ebeecc697dcad76df2d1","analyzedAt":"2026-09-03T14:18:07.398Z","contentChangedAt":"2026-09-03T14:18:07.398Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}