{"record":{"id":"2a88479e7ae941e4","repo":"apache/shenyu","slug":"invalid-port-in-redis-node-url-url","errorCode":null,"errorMessage":"Invalid port in Redis node URL: \" + url","messagePattern":"Invalid port 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":169,"sourceCode":"            }\n            int closingBracket = trimmedUrl.indexOf(\"]\");\n            if (closingBracket == -1 || closingBracket != bracketIndex) {\n                throw new IllegalArgumentException(\"Invalid IPv6 format in Redis node URL: \" + url);\n            }\n            \n            // Extract IPv6 address (remove brackets)\n            host = trimmedUrl.substring(1, closingBracket);\n            \n            // Check if port is specified after closing bracket\n            if (closingBracket < trimmedUrl.length() - 1 && trimmedUrl.charAt(closingBracket + 1) == ':') {\n                String portStr = trimmedUrl.substring(closingBracket + 2);\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            }\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);","sourceCodeStart":151,"sourceCodeEnd":187,"githubUrl":"https://github.com/apache/shenyu/blob/567142e07261b3e615ae8850b30f4421f455cc5d/shenyu-infra/shenyu-infra-redis/src/main/java/org/apache/shenyu/infra/redis/RedisConnectionFactory.java#L151-L187","documentation":"When the port substring after ']' (IPv6) or after the last colon (IPv4/hostname) is not parseable as an integer, parseRedisNode() throws this IllegalArgumentException wrapping the NumberFormatException. Default port 6379 is only used when no port is specified at all.","triggerScenarios":"Passing nodes like '127.0.0.1:abc', '[::1]:port', or 'localhost:99999' (out of int range is caught by parseInt too).","commonSituations":"Port variable interpolated as a non-numeric placeholder; port accidentally containing a unit ('6379tcp'); typo in the numeric port.","solutions":["Supply a valid numeric port (1-65535), e.g. 'localhost:6379'","Omit the port entirely to use the default 6379","Fix the env var/config source so the port value is numeric"],"exampleFix":"// before\nredis.node: \"localhost:${REDIS_PORT}\"\n// after (with validation)\nredis.node: \"localhost:6379\" // or ensure REDIS_PORT=\"6379\" is set","handlingStrategy":"validation","validationCode":"// check port is an integer in range before config load\nint c = nodeUrl.trim().lastIndexOf(':');\nif (c > 0 && c < nodeUrl.length() - 1) {\n    int p = Integer.parseInt(nodeUrl.substring(c + 1));\n    if (p < 1 || p > 65535) throw new IllegalArgumentException(\"Port out of range: \" + p);\n}","typeGuard":null,"tryCatchPattern":"try {\n    factory.create(List.of(nodeUrl));\n} catch (IllegalArgumentException e) {\n    if (e.getMessage().contains(\"Invalid port\")) {\n        logger.error(\"Non-numeric port in redis node: {}\", nodeUrl, e);\n    }\n    throw e;\n}","preventionTips":["Keep ports purely numeric — no service names, units, or spaces","Verify port env vars resolve to numbers at startup","Add a config schema check for node strings"],"tags":["redis","port","configuration","number-format"],"backgroundTag":"invalid-argument-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"}