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

  1. Open the definition file named in the message and inspect each comma-separated id token.
  2. Correct or remove malformed tokens; ensure no trailing/leading empty tokens from stray commas.
  3. 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

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

Related errors


AI-assisted analysis of elastic/elasticsearch@db6a809a66 (2026-08-12). Data as JSON: /api/errors/c20f8223c81fa387. Report an issue: GitHub.