{"record":{"id":"cc4e119306230194","repo":"lionsoul2014/ip2region","slug":"invalid-ip-address-ipstring","errorCode":null,"errorMessage":"invalid ip address '${ipString}'","messagePattern":"invalid ip address '(.+?)'","errorType":"validation","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"binding/javascript/util.js","lineNumber":145,"sourceCode":"        offset += 2;\n    }\n\n    return ipBytes;\n}\n\n\n// parse the specified string ip and return its bytes\n// @param  ip string\n// @return Buffer\nexport function parseIP(ipString) {\n    let sDot = ipString.indexOf('.');\n    let cDot = ipString.indexOf(':');\n    if (sDot > -1 && cDot == -1) {\n        return _parse_ipv4_addr(ipString);\n    } else if (cDot > -1) {\n        return _parse_ipv6_addr(ipString);\n    } else {\n        throw new Error(`invalid ip address '${ipString}'`);\n    }\n}\n\n// ---\n\n// ipv4 bytes to string\nfunction _ipv4_to_string(v4Bytes) {\n    return v4Bytes.join('.');\n}\n\n// ipv6 bytes to string\nfunction _ipv6_to_string(v6Bytes, compress) {\n    let ps = [], needCompress = false;\n    let lastHex = -1, hex = 0;\n    for (var i = 0; i < v6Bytes.length; i += 2) {\n        hex = v6Bytes.readUint16BE(i).toString(16);\n        ps.push(hex);\n     ","sourceCodeStart":127,"sourceCodeEnd":163,"githubUrl":"https://github.com/lionsoul2014/ip2region/blob/c1a1fc7d5941760db3f8431dc05c48cf7f0e30a1/binding/javascript/util.js#L127-L163","documentation":"Top-level dispatch guard in parseIP: the input string contains neither a dot nor a colon, so it cannot be routed to either the IPv4 or the IPv6 parser; it is not an IP address at all (e.g. 'localhost' or a bare number).","triggerScenarios":"Thrown at binding/javascript/util.js:145 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Pass a valid IPv4 or IPv6 string; resolve hostnames to IPs before searching","Validate the input with net.isIP before calling the searcher","Reject non-IP identifiers at the API boundary instead of inside search"],"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"}