{"record":{"id":"da629bc0d26e30bb","repo":"apache/shenyu","slug":"invalid-format-in-redis-node-url-url","errorCode":null,"errorMessage":"Invalid format in Redis node URL: \" + url","messagePattern":"Invalid format in Redis node URL: \" \\+ url","errorType":"validation","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"shenyu-infra/shenyu-infra-redis/src/main/java/org/apache/shenyu/infra/redis/RedisConnectionFactory.java","lineNumber":187,"sourceCode":"                    throw new IllegalArgumentException(\"Invalid port in Redis node URL: \" + url, e);\n                }\n            }\n        } else {\n            // IPv4 or hostname format: localhost:6379 or 192.168.1.1:6379\n            int lastColonIndex = trimmedUrl.lastIndexOf(\":\");\n            if (lastColonIndex > 0 && lastColonIndex < trimmedUrl.length() - 1) {\n                String portStr = trimmedUrl.substring(lastColonIndex + 1);\n                if (portStr.isEmpty()) {\n                    throw new IllegalArgumentException(\"Port cannot be empty in Redis node URL: \" + url);\n                }\n                try {\n                    port = Integer.parseInt(portStr);\n                } catch (NumberFormatException e) {\n                    throw new IllegalArgumentException(\"Invalid port in Redis node URL: \" + url, e);\n                }\n                host = trimmedUrl.substring(0, lastColonIndex);\n            } else if (lastColonIndex == 0 || lastColonIndex == trimmedUrl.length() - 1) {\n                throw new IllegalArgumentException(\"Invalid format in Redis node URL: \" + url);\n            }\n        }\n        \n        if (host.trim().isEmpty()) {\n            throw new IllegalArgumentException(\"Host is empty in Redis node URL: \" + url);\n        }\n        if (port < 1 || port > 65535) {\n            throw new IllegalArgumentException(\"Port out of range (1-65535) in Redis node URL: \" + url);\n        }\n        \n        return new RedisNode(host.trim(), port);\n    }\n}\n","sourceCodeStart":169,"sourceCodeEnd":201,"githubUrl":"https://github.com/apache/shenyu/blob/567142e07261b3e615ae8850b30f4421f455cc5d/shenyu-infra/shenyu-infra-redis/src/main/java/org/apache/shenyu/infra/redis/RedisConnectionFactory.java#L169-L201","documentation":"RedisConnectionFactory.parseRedisNode validates host:port node strings when building Redis cluster/sentinel nodes. If the string contains a colon but the colon is the first or last character (e.g. ':6379' or 'myhost:'), the host/port split is ambiguous and it throws IllegalArgumentException. This guards against malformed node URLs before a RedisNode is constructed.","triggerScenarios":"Passing a node string with a leading colon (no host), a trailing colon (no port), e.g. 'redis.nodes=:,host:, :6379' in cluster config parsed via redisNode/createRedisNode.","commonSituations":"Copy-paste of cluster node lists with stray separators, YAML/properties lists accidentally containing empty entries (trailing or leading commas yielding empty strings with colons), templated config where a host variable did not substitute.","solutions":["Fix the node URL so it is in host:port form, e.g. '127.0.0.1:6379'","Trim whitespace and remove empty entries from the configured node list","Log the full configured nodes string and correct the offending entry","Add pre-validation of node strings before calling RedisConnectionFactory"],"exampleFix":"// before\nshenyu.redis.nodes=192.168.0.1:6379,:6379,192.168.0.2:\n// after\nshenyu.redis.nodes=192.168.0.1:6379,192.168.0.2:6379","handlingStrategy":"validation","validationCode":"boolean isValidNode(String url) {\n    if (url == null) return false;\n    String t = url.trim();\n    int i = t.lastIndexOf(':');\n    return i > 0 && i < t.length() - 1;\n}","typeGuard":null,"tryCatchPattern":"try {\n    RedisNode node = RedisConnectionFactory.parseRedisNode(url);\n} catch (IllegalArgumentException e) {\n    log.error(\"bad redis node url: {}\", url, e);\n    throw new ConfigurationException(\"fix redis.nodes entry\", e);\n}","preventionTips":["Keep node lists in host:port form with no empty entries","Trim and filter blank items before parsing","Use the default port 6379 explicitly in config","Add a config validation step at application startup"],"tags":["redis","configuration","url-parsing"],"backgroundTag":"invalid-url-format","analyzedSha":"567142e07261b3e615ae8850b30f4421f455cc5d","analyzedAt":"2026-09-12T10:08:21.293Z","contentChangedAt":"2026-09-12T10:08:21.293Z","schemaVersion":2},"datasetVersion":"2026-09-16T04:17:20.429Z"}