{"record":{"id":"49b102c05178faeb","repo":"apache/dubbo","slug":"there-is-wrong-format-of-ip-address-mask-i","errorCode":null,"errorMessage":"There is wrong format of ip Address: ${mask[i]}","messagePattern":"There is wrong format of ip Address: (.+?)","errorType":"validation","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"dubbo-common/src/main/java/org/apache/dubbo/common/utils/NetUtils.java","lineNumber":819,"sourceCode":"        if (pattern.equals(host)) {\n            return true;\n        }\n\n        // short name condition\n        if (!ipPatternContainExpression(pattern)) {\n            InetAddress patternAddress = InetAddress.getByName(pattern);\n            return patternAddress.getHostAddress().equals(host);\n        }\n\n        String[] ipAddress = host.split(splitCharacter);\n\n        for (int i = 0; i < mask.length; i++) {\n            if (\"*\".equals(mask[i]) || mask[i].equals(ipAddress[i])) {\n                continue;\n            } else if (mask[i].contains(\"-\")) {\n                String[] rangeNumStrs = StringUtils.split(mask[i], '-');\n                if (rangeNumStrs.length != 2) {\n                    throw new IllegalArgumentException(\"There is wrong format of ip Address: \" + mask[i]);\n                }\n                Integer min = getNumOfIpSegment(rangeNumStrs[0], isIpv4);\n                Integer max = getNumOfIpSegment(rangeNumStrs[1], isIpv4);\n                Integer ip = getNumOfIpSegment(ipAddress[i], isIpv4);\n                if (ip < min || ip > max) {\n                    return false;\n                }\n            } else if (\"0\".equals(ipAddress[i])\n                    && (\"0\".equals(mask[i])\n                            || \"00\".equals(mask[i])\n                            || \"000\".equals(mask[i])\n                            || \"0000\".equals(mask[i]))) {\n                continue;\n            } else if (!mask[i].equals(ipAddress[i])) {\n                return false;\n            }\n        }\n        return true;","sourceCodeStart":801,"sourceCodeEnd":837,"githubUrl":"https://github.com/apache/dubbo/blob/3a3043227f5571d25eb2889de5bca22f2914843b/dubbo-common/src/main/java/org/apache/dubbo/common/utils/NetUtils.java#L801-L837","documentation":"Inside IP-range matching, a segment containing '-' is split on '-' and must yield exactly two parts (min-max). If a segment like '1-2-3' or '-5' splits into != 2 parts, the range is malformed and IllegalArgumentException is thrown.","triggerScenarios":"Configuring an IP pattern segment with multiple hyphens or a dangling hyphen, e.g. '192.168.1.1-2-3' or '10.0.0.-5', which fails the two-part range expectation.","commonSituations":"Hand-edited ACL/rule files with typos in range segments; copy-paste errors; misunderstanding that ranges are min-max only (no chained ranges).","solutions":["Correct the segment to a single 'min-max' range (e.g. '192.168.1.1-3')","Validate each segment splits into exactly two numeric parts before applying the rule","Use '*' for whole-segment wildcards instead of malformed ranges"],"exampleFix":"# before\nallow-ip: 192.168.1.1-2-3\n# after\nallow-ip: 192.168.1.1-3","handlingStrategy":"validation","validationCode":"for (String seg : mask) {\n    if (seg.contains(\"-\")) {\n        String[] parts = seg.split(\"-\");\n        if (parts.length != 2) { /* malformed; reject rule before NetUtils sees it */ }\n    }\n}","typeGuard":"static boolean validRangeSegment(String seg) {\n    if (!seg.contains(\"-\")) return true;\n    String[] p = seg.split(\"-\");\n    return p.length == 2;\n}","tryCatchPattern":"try { NetUtils.matchIpRange(pattern, host, port); }\ncatch (IllegalArgumentException e) { /* a range segment was malformed */ }","preventionTips":["Validate ACL rule files at startup","Use single min-max ranges; never chain with extra hyphens"],"tags":["network","ip","config","validation"],"backgroundTag":null,"analyzedSha":"3a3043227f5571d25eb2889de5bca22f2914843b","analyzedAt":"2026-08-14T00:43:19.853Z","schemaVersion":2},"datasetVersion":"2026-08-14T05:17:29.042Z"}