apache/shenyu · error · IllegalArgumentException
Host is empty in Redis node URL: " + url
Error message
Host is empty in Redis node URL: " + url
What it means
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.
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
Example fix
// before
shenyu.redis.nodes=${REDIS_HOST}:6379 // REDIS_HOST unset -> ':6379'
// after
shenyu.redis.nodes=127.0.0.1:6379 Defensive patterns
Strategy: validation
Validate before calling
boolean hasHost(String url) {
if (url == null) return false;
String t = url.trim();
int i = t.lastIndexOf(':');
return i > 0 && !t.substring(0, i).trim().isEmpty();
} Try / catch
try {
RedisNode node = factory.parseRedisNode(url);
} catch (IllegalArgumentException e) {
log.error("redis node missing host: {}", url);
}
Prevention
- 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
When it happens
Trigger: A node URL whose host portion is empty or whitespace after colon-splitting, e.g. ' :6379' or ':6379 ' passed into redisNode/createRedisNode.
Common situations: 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.
Understand the failure class
Background: "must not be empty", "cannot be empty" — required-field validation errors across open-source libraries — this error's family across 41 libraries.
Related errors
- Redis node URL cannot be null or empty
- Port cannot be empty in Redis node URL: " + url
- client register param must config the appName or contextPath
- The configuration shenyu.discovery.serverList in xml/yml…
- OpenAPI pathKey cannot be null or empty
AI-assisted analysis of apache/shenyu@567142e072 (2026-09-12).
Data as JSON: /api/errors/b817a0055a22c499.
Report an issue: GitHub.
Appendix: source
Thrown at shenyu-infra/shenyu-infra-redis/src/main/java/org/apache/shenyu/infra/redis/RedisConnectionFactory.java:192
int lastColonIndex = trimmedUrl.lastIndexOf(":");
if (lastColonIndex > 0 && lastColonIndex < trimmedUrl.length() - 1) {
String portStr = trimmedUrl.substring(lastColonIndex + 1);
if (portStr.isEmpty()) {
throw new IllegalArgumentException("Port cannot be empty in Redis node URL: " + url);
}
try {
port = Integer.parseInt(portStr);
} catch (NumberFormatException e) {
throw new IllegalArgumentException("Invalid port in Redis node URL: " + url, e);
}
host = trimmedUrl.substring(0, lastColonIndex);
} else if (lastColonIndex == 0 || lastColonIndex == trimmedUrl.length() - 1) {
throw new IllegalArgumentException("Invalid format in Redis node URL: " + url);
}
}
if (host.trim().isEmpty()) {
throw new IllegalArgumentException("Host is empty in Redis node URL: " + url);
}
if (port < 1 || port > 65535) {
throw new IllegalArgumentException("Port out of range (1-65535) in Redis node URL: " + url);
}
return new RedisNode(host.trim(), port);
}
}
View on GitHub (pinned to 567142e072)