{"record":{"id":"576c597de78ed4f6","repo":"apache/dubbo","slug":"illegal-argument-pattern-or-hostname-pattern-pa","errorCode":null,"errorMessage":"Illegal Argument pattern or hostName. Pattern:${pattern}, Host:${host}","messagePattern":"Illegal Argument pattern or hostName\\. Pattern:(.+?), Host:(.+?)","errorType":"validation","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"dubbo-common/src/main/java/org/apache/dubbo/common/utils/NetUtils.java","lineNumber":776,"sourceCode":"        // if the pattern is subnet format, it will not be allowed to config port param in pattern.\n        if (pattern.contains(\"/\")) {\n            CIDRUtils utils = new CIDRUtils(pattern);\n            return utils.isInRange(host);\n        }\n\n        return matchIpRange(pattern, host, port);\n    }\n\n    /**\n     * @param pattern\n     * @param host\n     * @param port\n     * @return\n     * @throws UnknownHostException\n     */\n    public static boolean matchIpRange(String pattern, String host, int port) throws UnknownHostException {\n        if (pattern == null || host == null) {\n            throw new IllegalArgumentException(\n                    \"Illegal Argument pattern or hostName. Pattern:\" + pattern + \", Host:\" + host);\n        }\n        pattern = pattern.trim();\n        if (\"*.*.*.*\".equals(pattern) || \"*\".equals(pattern)) {\n            return true;\n        }\n\n        InetAddress inetAddress = InetAddress.getByName(host);\n        boolean isIpv4 = isValidV4Address(inetAddress);\n        String[] hostAndPort = getPatternHostAndPort(pattern, isIpv4);\n        if (hostAndPort[1] != null && !hostAndPort[1].equals(String.valueOf(port))) {\n            return false;\n        }\n        pattern = hostAndPort[0];\n\n        String splitCharacter = SPLIT_IPV4_CHARACTER;\n        if (!isIpv4) {\n            splitCharacter = SPLIT_IPV6_CHARACTER;","sourceCodeStart":758,"sourceCodeEnd":794,"githubUrl":"https://github.com/apache/dubbo/blob/3a3043227f5571d25eb2889de5bca22f2914843b/dubbo-common/src/main/java/org/apache/dubbo/common/utils/NetUtils.java#L758-L794","documentation":"NetUtils.matchIpRange requires both the pattern and the host to be non-null. If either is null it throws IllegalArgumentException because IP-range matching is undefined without both operands.","triggerScenarios":"Calling NetUtils.matchIpRange(pattern, host, port) (or the IP-expression matcher) where pattern or host resolved to null — e.g. from a missing config value or an unresolvable remote address.","commonSituations":"Firewall/ACL rules referencing an unset 'dubbo.ip-pattern' property; a remote socket whose host string could not be resolved; null propagation from a previous lookup step.","solutions":["Validate that both pattern and host are non-null before calling matchIpRange","Provide explicit defaults for optional pattern config and skip matching when unset","Log the unresolved host early so the null source is traceable"],"exampleFix":"// before\nif (NetUtils.matchIpRange(configPattern, remoteHost, port)) { ... }\n// after\nif (configPattern != null && remoteHost != null\n        && NetUtils.matchIpRange(configPattern, remoteHost, port)) { ... }","handlingStrategy":"validation","validationCode":"if (pattern == null || host == null) { /* skip or default; do not call matchIpRange */ }\nelse { boolean ok = NetUtils.matchIpRange(pattern, host, port); }","typeGuard":"static boolean canMatchIp(String pattern, String host) { return pattern != null && host != null; }","tryCatchPattern":"try { NetUtils.matchIpRange(pattern, host, port); }\ncatch (IllegalArgumentException e) { /* pattern or host was null */ }","preventionTips":["Default ACL pattern properties to a non-null value","Resolve remote host before invoking matchers"],"tags":["network","ip","validation"],"backgroundTag":null,"analyzedSha":"3a3043227f5571d25eb2889de5bca22f2914843b","analyzedAt":"2026-08-14T00:43:19.853Z","schemaVersion":2},"datasetVersion":"2026-08-14T05:17:29.042Z"}