{"record":{"id":"f3959cd6a649638c","repo":"apache/shenyu","slug":"port-cannot-be-empty-in-redis-node-url-url","errorCode":null,"errorMessage":"Port cannot be empty in Redis node URL: \" + url","messagePattern":"Port cannot be empty 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":164,"sourceCode":"        \n        if (bracketIndex > -1) {\n            // IPv6 address format: [::1] or [::1]:6379\n            if (!trimmedUrl.startsWith(\"[\")) {\n                throw new IllegalArgumentException(\"Invalid IPv6 format in Redis node URL: \" + url);\n            }\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) {","sourceCodeStart":146,"sourceCodeEnd":182,"githubUrl":"https://github.com/apache/shenyu/blob/567142e07261b3e615ae8850b30f4421f455cc5d/shenyu-infra/shenyu-infra-redis/src/main/java/org/apache/shenyu/infra/redis/RedisConnectionFactory.java#L146-L182","documentation":"For a bracketed IPv6 node like '[::1]:', if a colon follows the closing bracket the port substring must be non-empty. '[::1]:' yields an empty port string and parseRedisNode() throws this IllegalArgumentException.","triggerScenarios":"Passing '[::1]:' or '[2001:db8::1]: ' (colon present, no digits after it).","commonSituations":"Truncated config value where the port digits were lost; template with an unset port variable rendered as nothing.","solutions":["Add the port after the colon, e.g. '[::1]:6379'","Remove the trailing colon entirely to use the default port 6379","Set the port variable in the environment/template before deployment"],"exampleFix":"// before\nredis.node: \"[::1]:\"\n// after\nredis.node: \"[::1]:6379\"","handlingStrategy":"validation","validationCode":"// require digits if a port colon is present\nString t = nodeUrl.trim();\nint c = t.lastIndexOf(':');\nif (c > 0 && c < t.length() - 1 && !t.substring(c + 1).chars().allMatch(Character::isDigit)) {\n    throw new IllegalArgumentException(\"Port must be numeric: \" + nodeUrl);\n}","typeGuard":null,"tryCatchPattern":"try {\n    factory.create(List.of(nodeUrl));\n} catch (IllegalArgumentException e) {\n    if (e.getMessage().contains(\"Port cannot be empty\")) {\n        logger.error(\"Node URL has ':' with no port digits: {}\", nodeUrl, e);\n    }\n    throw e;\n}","preventionTips":["Ensure port env vars are set and non-empty before rendering config","Omit the colon entirely when using default port 6379","Validate rendered config at startup"],"tags":["redis","port","configuration","validation"],"backgroundTag":"empty-required-field","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"}