{"record":{"id":"701e7c9b6dfbe45b","repo":"apache/shenyu","slug":"port-out-of-range-1-65535-in-redis-node-url-url","errorCode":null,"errorMessage":"Port out of range (1-65535) in Redis node URL: \" + url","messagePattern":"Port out of range \\(1-65535\\) 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":195,"sourceCode":"                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":177,"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#L177-L201","documentation":"parseRedisNode validates that the parsed port is within the valid TCP range 1-65535 before creating a RedisNode. Ports outside that range (0, negative, or >65535) are invalid and produce this IllegalArgumentException. Note the port parse itself already rejects non-numeric values with a separate error.","triggerScenarios":"A node URL like '127.0.0.1:0', '127.0.0.1:99999', or '127.0.0.1:-1' passed to redisNode/createRedisNode.","commonSituations":"Typo in the port number, copy-pasted port from another service, misremembering the Redis default (6379), config template with an out-of-range placeholder value.","solutions":["Correct the port to a valid value in 1-65535 (Redis default is 6379)","Check the actual port your Redis server listens on (redis-cli ping / CONFIG GET port)","Validate port range in configuration before passing node URLs","Search config files for suspicious ports like 0 or values above 65535"],"exampleFix":"// before\nshenyu.redis.nodes=127.0.0.1:99999\n// after\nshenyu.redis.nodes=127.0.0.1:6379","handlingStrategy":"validation","validationCode":"boolean validPort(String url) {\n    int i = url == null ? -1 : url.trim().lastIndexOf(':');\n    if (i < 0 || i == url.trim().length() - 1) return false;\n    try {\n        int p = Integer.parseInt(url.trim().substring(i + 1));\n        return p >= 1 && p <= 65535;\n    } catch (NumberFormatException e) { return false; }\n}","typeGuard":null,"tryCatchPattern":"try {\n    RedisNode node = factory.parseRedisNode(url);\n} catch (IllegalArgumentException e) {\n    log.error(\"redis node port invalid: {}\", url);\n}","preventionTips":["Use 6379 unless intentionally different","Range-check ports parsed from config","Grep configs for ports outside 1-65535 before deploy"],"tags":["redis","configuration","port"],"backgroundTag":"value-out-of-range","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"}