apache/pulsar · error · IllegalArgumentException
Invalid string to parse WorkerInfo : ${str}
Error message
Invalid string to parse WorkerInfo : ${str} What it means
WorkerInfo.parseFrom splits a 'workerId:hostname:port' string on ':' and throws IllegalArgumentException if the string does not have exactly 3 tokens. It is a strict format parser for worker identification strings used by the functions worker metadata.
Source
Thrown at pulsar-client-admin-api/src/main/java/org/apache/pulsar/common/functions/WorkerInfo.java:48
*/
@Getter
@AllArgsConstructor(access = AccessLevel.PRIVATE)
@NoArgsConstructor
@ToString
@CustomLog
public class WorkerInfo {
private String workerId;
private String workerHostname;
private int port;
public static WorkerInfo of(String workerId, String workerHostname, int port) {
return new WorkerInfo(workerId, workerHostname, port);
}
public static WorkerInfo parseFrom(String str) {
String[] tokens = str.split(":");
if (tokens.length != 3) {
throw new IllegalArgumentException("Invalid string to parse WorkerInfo : " + str);
}
String workerId = tokens[0];
String workerHostname = tokens[1];
try {
int port = Integer.parseInt(tokens[2]);
return new WorkerInfo(workerId, workerHostname, port);
} catch (NumberFormatException nfe) {
log.warn().attr("workerInfo", str).log("Invalid worker info");
throw nfe;
}
}
}
View on GitHub (pinned to 820761864e)
Solutions
- Ensure the input string is exactly workerId:hostname:port with no extra or missing colons
- Pre-validate with str.split(":").length == 3 before calling parseFrom
- For IPv6 hosts, use a bracketed form or a different serialization that avoids ':' ambiguity
- If reading stored metadata, check which component/version wrote it and re-serialize in the expected format
Example fix
// before
WorkerInfo info = WorkerInfo.parseFrom(config.getWorkerString());
// after
String s = config.getWorkerString();
if (s == null || s.split(":").length != 3) {
throw new IllegalArgumentException("Expected workerId:hostname:port, got: " + s);
}
WorkerInfo info = WorkerInfo.parseFrom(s); Defensive patterns
Strategy: validation
Validate before calling
boolean isParseableWorkerInfo(String s) {
return s != null && s.split(":", -1).length == 3;
} Try / catch
try {
WorkerInfo info = WorkerInfo.parseFrom(str);
} catch (IllegalArgumentException e) {
logger.error("Bad WorkerInfo string '{}': {}", str, e.getMessage());
} Prevention
- Always serialize with WorkerInfo's own toString/format, never hand-concatenate
- Beware IPv6 hostnames containing ':'
- Trim and validate stored metadata strings after upgrades
When it happens
Trigger: Calling WorkerInfo.parseFrom(str) with a string that doesn't contain exactly two ':' separators, e.g. an empty string, a hostname containing ':' (IPv6), or a malformed/legacy serialization.
Common situations: Storing worker info in config files or ZooKeeper metadata with a wrong format, IPv6 hostnames adding extra colons, copy-paste errors with whitespace, or reading a value written by a different serialization format.
Related errors
- Invalid txnId key:
- Invalid value %s for the position. Allowed values are [lates
- Invalid topic domain: '${value}'
- Invalid format for fully qualified instance name:
- Positions must not be null
AI-assisted analysis of apache/pulsar@820761864e (2026-09-06).
Data as JSON: /api/errors/c7cd6182018f71b8.
Report an issue: GitHub.