{"record":{"id":"99123471c83474f2","repo":"nodejs/node","slug":"und-err-invalid-arg-991234","errorCode":"UND_ERR_INVALID_ARG","errorMessage":"Domain name too long (max 255 bytes)","messagePattern":"Domain name too long \\(max 255 bytes\\)","errorType":"exception","errorClass":"InvalidArgumentError","httpStatus":null,"severity":"error","filePath":"deps/undici/src/lib/core/socks5-utils.js","lineNumber":33,"sourceCode":"    const parts = address.split('.').map(Number)\n    return {\n      type: 0x01, // IPv4\n      buffer: Buffer.from(parts)\n    }\n  }\n\n  // Check if it's an IPv6 address\n  if (net.isIPv6(address)) {\n    return {\n      type: 0x04, // IPv6\n      buffer: parseIPv6(address)\n    }\n  }\n\n  // Otherwise, treat as domain name\n  const domainBuffer = Buffer.from(address, 'utf8')\n  if (domainBuffer.length > 255) {\n    throw new InvalidArgumentError('Domain name too long (max 255 bytes)')\n  }\n\n  return {\n    type: 0x03, // Domain\n    buffer: Buffer.concat([Buffer.from([domainBuffer.length]), domainBuffer])\n  }\n}\n\n/**\n * Parse IPv6 address to buffer\n * @param {string} address - IPv6 address string\n * @returns {Buffer} 16-byte buffer\n */\nfunction parseIPv6 (address) {\n  const buffer = Buffer.alloc(16)\n  let normalizedAddress = address\n\n  // Expand an embedded IPv4 tail into the last two IPv6 groups.","sourceCodeStart":15,"sourceCodeEnd":51,"githubUrl":"https://github.com/nodejs/node/blob/1b2de5e052fc0fb95fd7fb6846dcec4ade598e9e/deps/undici/src/lib/core/socks5-utils.js#L15-L51","documentation":"Thrown by the address-encoding helper in socks5-utils when a domain name encodes to more than 255 UTF-8 bytes. RFC 1928 encodes the domain length as a single byte, so the domain must be at most 255 bytes. This is a hard protocol limit on the target address.","triggerScenarios":"Passing an extremely long hostname as the connect target; a malformed or concatenated address string; an address that is not really a hostname but a long blob.","commonSituations":"Bug constructing the target address; SNI/host header accidentally passed as the address; a very long generated subdomain.","solutions":["Validate the target hostname length before calling connect.","Fix the upstream code that produced an overlong address.","Use Buffer.byteLength(address,'utf8') to check, since multibyte chars inflate byte length."],"exampleFix":"// before\nclient.connect(veryLongHostname, port)\n\n// after\nif (Buffer.byteLength(host, 'utf8') > 255) throw new Error('host too long for SOCKS5 DOMAIN ATYP')\nclient.connect(host, port)","handlingStrategy":"validation","validationCode":"function assertHostLength(host) {\n  if (Buffer.byteLength(host, 'utf8') > 255) {\n    throw new Error('host exceeds 255-byte SOCKS5 DOMAIN limit')\n  }\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Validate target host byte length before connect.","Check for accidentally concatenated address strings.","Prefer IP literals when you have them to skip the DOMAIN path."],"tags":["socks5","proxy","validation","rfc-1928","address"],"backgroundTag":null,"analyzedSha":"1b2de5e052fc0fb95fd7fb6846dcec4ade598e9e","analyzedAt":"2026-08-13T00:53:24.642Z","schemaVersion":2},"datasetVersion":"2026-08-13T04:17:16.726Z"}