elastic/elasticsearch · error · IllegalStateException
Failed to parse id {} in {}
Error message
Failed to parse id {} in {} What it means
IllegalStateException from TransportVersionDefinition.fromString() wrapping a NumberFormatException raised by TransportVersionId.fromString(rawId). Each comma-separated id in the definition file must parse as a valid transport-version id integer/string form.
Source
Thrown at build-tools-internal/src/main/java/org/elasticsearch/gradle/internal/transport/TransportVersionDefinition.java:41
String idsLine = null;
if (contents.isEmpty() == false) {
// Regardless of whether windows newlines exist (they could be added by git), we split on line feed.
// All we care about skipping lines with the comment character, so the remaining \r won't matter
String[] lines = contents.split("\n");
for (String line : lines) {
line = line.strip();
if (line.startsWith("#") == false) {
idsLine = line;
break;
}
}
}
if (idsLine != null) {
for (String rawId : idsLine.split(",")) {
try {
ids.add(TransportVersionId.fromString(rawId));
} catch (NumberFormatException e) {
throw new IllegalStateException("Failed to parse id " + rawId + " in " + file, e);
}
}
}
return new TransportVersionDefinition(name, ids, isReferable);
}
}
View on GitHub (pinned to db6a809a66)
Solutions
- Open the definition file named in the message and inspect each comma-separated id token.
- Correct or remove malformed tokens; ensure no trailing/leading empty tokens from stray commas.
- Validate against TransportVersionId.fromString's expected format before committing.
Example fix
// before: initial_25.csv contains "1000000,abc,1000002" // after: initial_25.csv contains "1000000,1000001,1000002"
Defensive patterns
Strategy: try-catch
Validate before calling
for (String rawId : idsLine.split(",")) {
String t = rawId.strip();
if (t.isEmpty() || !t.matches("\\d+")) {
throw new IllegalStateException("Bad id '" + rawId + "' in " + file);
}
} Type guard
static boolean isValidId(String s) { return s != null && s.matches("\\d+"); } Try / catch
try {
TransportVersionDefinition.fromString(file, contents, isReferable);
} catch (IllegalStateException e) {
if (e.getMessage().startsWith("Failed to parse id")) {
// report file:token and prompt author to fix the CSV
logger.error("Malformed definition file {}", file, e);
}
throw e;
} Prevention
- Validate CSV id tokens before committing transport-version files.
- Avoid trailing commas that produce empty tokens.
- Run a lint check over the resources directory in CI.
When it happens
Trigger: A definition CSV's ids line contains a token that is not a valid TransportVersionId - non-numeric text, a stray comma producing an empty token, or a malformed id format.
Common situations: Hand-editing a definition CSV and introducing a typo/whitespace; a merge conflict artifact left in the file; an empty trailing token from a trailing comma.
Understand the failure class
- Parsing and encoding errors: unexpected token, malformed input — why parsers reject input and how to find the real culprit.
Related errors
- Invalid transport version data file [{}]: {}
- Invalid transport version upper bound file [{}]: {}
- Could not find base id: {}
- Could not find base id: {}
- Invalid increment {}, must be a positive integer
AI-assisted analysis of elastic/elasticsearch@db6a809a66 (2026-08-12).
Data as JSON: /api/errors/c20f8223c81fa387.
Report an issue: GitHub.