{"record":{"id":"b817a0055a22c499","repo":"apache/shenyu","slug":"host-is-empty-in-redis-node-url-url","errorCode":null,"errorMessage":"Host is empty in Redis node URL: \" + url","messagePattern":"Host is 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":192,"sourceCode":"            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":174,"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#L174-L201","documentation":"After parsing host and port from a Redis node URL, parseRedisNode checks that the extracted host is not blank. An empty host means the URL was malformed (e.g. ':6379') so it throws IllegalArgumentException. This ensures RedisNode is never created with an empty hostname.","triggerScenarios":"A node URL whose host portion is empty or whitespace after colon-splitting, e.g. ' :6379' or ':6379 ' passed into redisNode/createRedisNode.","commonSituations":"Empty or blank entries in a comma-separated node list in cluster/sentinel configuration, unresolved placeholder like '${redis.host}:6379' leaving the host blank in some environments.","solutions":["Provide a non-empty host for every configured node, e.g. '127.0.0.1:6379'","Filter out blank entries before parsing the node list","Check environment variable/placeholder resolution so the host is actually substituted","Validate the nodes configuration at startup before building the connection factory"],"exampleFix":"// before\nshenyu.redis.nodes=${REDIS_HOST}:6379  // REDIS_HOST unset -> ':6379'\n// after\nshenyu.redis.nodes=127.0.0.1:6379","handlingStrategy":"validation","validationCode":"boolean hasHost(String url) {\n    if (url == null) return false;\n    String t = url.trim();\n    int i = t.lastIndexOf(':');\n    return i > 0 && !t.substring(0, i).trim().isEmpty();\n}","typeGuard":null,"tryCatchPattern":"try {\n    RedisNode node = factory.parseRedisNode(url);\n} catch (IllegalArgumentException e) {\n    log.error(\"redis node missing host: {}\", url);\n}\n","preventionTips":["Never leave host placeholders like ${REDIS_HOST} unresolved","Filter blank entries out of comma-separated node lists","Validate env vars used in hosts are set before deployment"],"tags":["redis","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"}