{"record":{"id":"f6e1a78f9a38c2db","repo":"lionsoul2014/ip2region","slug":"invalid-ipv6-address","errorCode":null,"errorMessage":"invalid ipv6 address","messagePattern":"invalid ipv6 address","errorType":"validation","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"binding/javascript/util.js","lineNumber":79,"sourceCode":"        if (isNaN(v)) {\n            throw new Error(`invalid ipv4 part '${ps[i]}', a valid number expected`);\n        }\n\n        if (v < 0 || v > 255) {\n            throw new Error(`invalid ipv4 part '${ps[i]}' should >= 0 and <= 255`);\n        }\n\n        ipBytes[i] = (v & 0xFF);\n    }\n\n    return ipBytes;\n}\n\n// parse ipv6 address\nfunction _parse_ipv6_addr(v6String) {\n    let ps = v6String.split(':', 8);\n    if (ps.length < 3) {\n        throw new Error('invalid ipv6 address');\n    }\n\n    let dc_num = 0, offset = 0;\n    const ipBytes = Buffer.alloc(16);\n    for (var i = 0; i < ps.length; i++) {\n        let s = ps[i].trim();\n\n        // Double colon check and auto padding\n        if (s.length == 0) {\n            // ONLY one double colon allow\n            if (dc_num > 0) {\n                throw new Error('invalid ipv6 address: multi double colon detected');\n            }\n\n            let start = i, mi = ps.length - 1;\n            // clear all the consecutive spaces\n            for (i++;;) {\n                s = ps[i].trim();","sourceCodeStart":61,"sourceCodeEnd":97,"githubUrl":"https://github.com/lionsoul2014/ip2region/blob/c1a1fc7d5941760db3f8431dc05c48cf7f0e30a1/binding/javascript/util.js#L61-L97","documentation":"Structural guard in the IPv6 parser: the string contained a colon (so it was routed to the v6 parser) but splitting on ':' produced fewer than 3 groups, which is too short to be any legal IPv6 form (even '::' yields 3 parts).","triggerScenarios":"Thrown at binding/javascript/util.js:79 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Pass a complete IPv6 address such as '2001:db8::1' or '1:2:3:4:5:6:7:8'","Pre-check with net.isIPv6 (or equivalent) before parsing","Ensure the string was not truncated before reaching the parser"],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"c1a1fc7d5941760db3f8431dc05c48cf7f0e30a1","analyzedAt":"2026-09-02T16:58:39.988Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-09T21:17:11.164Z"}