{"record":{"id":"1eb96ade3ef3aa2e","repo":"apache/shenyu","slug":"invalid-ipv6-format-in-redis-node-url-url","errorCode":null,"errorMessage":"Invalid IPv6 format in Redis node URL: \" + url","messagePattern":"Invalid IPv6 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":150,"sourceCode":"            redisNodes.add(parseRedisNode(node));\n        }\n        return redisNodes;\n    }\n\n    private RedisNode parseRedisNode(final String url) {\n        if (Objects.isNull(url) || url.trim().isEmpty()) {\n            throw new IllegalArgumentException(\"Redis node URL cannot be null or empty\");\n        }\n        \n        String trimmedUrl = url.trim();\n        String host = trimmedUrl;\n        int port = 6379;\n        int bracketIndex = trimmedUrl.lastIndexOf(\"]\");\n        \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) {","sourceCodeStart":132,"sourceCodeEnd":168,"githubUrl":"https://github.com/apache/shenyu/blob/567142e07261b3e615ae8850b30f4421f455cc5d/shenyu-infra/shenyu-infra-redis/src/main/java/org/apache/shenyu/infra/redis/RedisConnectionFactory.java#L132-L168","documentation":"When a Redis node URL contains ']' (so it is treated as bracketed IPv6), it must start with '['. A URL like '192.168.1.1]' or '::1]' is malformed, and parseRedisNode() throws this IllegalArgumentException (note the message is built with string concatenation, so the thrown text is the concatenation result).","triggerScenarios":"Passing a node string containing ']' that does not begin with '[', e.g. 'myhost]:6379' or a partially bracketed IPv6 '::1]:6379'.","commonSituations":"Hand-edited Redis cluster config where only one bracket of '[::1]:6379' survived; copy/paste from documentation dropping the opening bracket.","solutions":["Supply the full bracketed IPv6 form, e.g. '[::1]:6379'","Use a hostname or plain IPv4 like '127.0.0.1:6379' if IPv6 is not required","Escape/quote the value in YAML/properties so brackets are not stripped by the config parser"],"exampleFix":"// before\nredis.nodes: [\"::1]:6379\"]\n// after\nredis.nodes: [\"[::1]:6379\"]","handlingStrategy":"validation","validationCode":"// validate before passing the node string\njava.util.regex.Pattern NODE = Pattern.compile(\"^(\\\\[[0-9a-fA-F:.%]+\\\\])(:\\\\d{1,5})?$|^([^\\\\[\\]]+)(:\\\\d{1,5})?$\");\nif (!NODE.matcher(nodeUrl.trim()).matches()) throw new IllegalArgumentException(\"Bad redis node: \" + nodeUrl);","typeGuard":null,"tryCatchPattern":"try {\n    factory.create(List.of(nodeUrl));\n} catch (IllegalArgumentException e) {\n    if (e.getMessage().contains(\"Invalid IPv6 format\")) {\n        logger.error(\"Fix bracketed IPv6 node URL: {}\", nodeUrl, e);\n    }\n    throw e;\n}","preventionTips":["Always use the full '[ipv6]:port' form for IPv6 nodes","Quote values containing brackets in YAML/properties","Add startup validation of node URLs with a regex"],"tags":["redis","ipv6","configuration","url-format"],"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"}