{"record":{"id":"0032a6c968b29845","repo":"lionsoul2014/ip2region","slug":"invalid-ipv4-address","errorCode":null,"errorMessage":"invalid ipv4 address","messagePattern":"invalid ipv4 address","errorType":"validation","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"binding/javascript/util.js","lineNumber":54,"sourceCode":"    toString() {\n        return `{\n            \"version\":${this.version}, \n            \"index_policy\":${this.indexPolicy},\n            \"start_index_ptr\": ${this.startIndexPtr},\n            \"end_index_ptr\": ${this.endIndexPtr},\n            \"ipVersion\": ${this.ipVersion},\n            \"runtime_ptr_bytes\": ${this.runtimePtrBytes}\n        }`;\n    }\n}\n\n// ---\n\n// parse ipv4 address\nfunction _parse_ipv4_addr(v4String) {\n    let ps = v4String.split('.', 4);\n    if (ps.length != 4) {\n        throw new Error('invalid ipv4 address');\n    }\n\n    var v;\n    const ipBytes =  Buffer.alloc(4);\n    for (var i = 0; i < ps.length; i++) {\n        v = parseInt(ps[i], 10);\n        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;","sourceCodeStart":36,"sourceCodeEnd":72,"githubUrl":"https://github.com/lionsoul2014/ip2region/blob/c1a1fc7d5941760db3f8431dc05c48cf7f0e30a1/binding/javascript/util.js#L36-L72","documentation":"Validation guard inside the IPv4 parser: the input was routed here because it contained a dot and no colon, but splitting on '.' did not yield exactly 4 octets (e.g. '1.2.3' or '1.2.3.4.5'). The address is structurally not dotted-quad IPv4.","triggerScenarios":"Thrown at binding/javascript/util.js:54 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Supply a well-formed dotted-quad IPv4 address such as '1.2.3.4'","Validate the string with a regex or net.isIPv4 before calling search/parseIP","If the input is actually IPv6, remove the dots or pass the v6 string to a v6-capable searcher"],"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"}