elastic/elasticsearch · error · IllegalArgumentException
Incorrect format for line [%s]
Error message
Incorrect format for line [%s]
What it means
Thrown in TagVersionsTask.addVersionRecord() while parsing the existing version-record file: every line must match (\d+\.\d+\.\d+),(\d+). Any line that does not match (blank, comment, malformed, BOM, wrong separator) aborts the whole parse.
Source
Thrown at build-tools-internal/src/main/java/org/elasticsearch/gradle/internal/release/TagVersionsTask.java:105
}
}
/*
* V7 just extracts a single Version. If so, this version needs to be applied to transport and index versions.
*/
private static Map<String, Integer> expandV7Version(Map<String, Integer> tagVersions) {
Integer v7Version = tagVersions.get("Version");
if (v7Version == null) return tagVersions;
return Map.of(INDEX_VERSION_TYPE, v7Version);
}
private static final Pattern VERSION_LINE = Pattern.compile("(\\d+\\.\\d+\\.\\d+),(\\d+)");
static Optional<List<String>> addVersionRecord(List<String> versionRecordLines, Version release, int id) {
Map<Version, Integer> versions = versionRecordLines.stream().map(l -> {
Matcher m = VERSION_LINE.matcher(l);
if (m.matches() == false) throw new IllegalArgumentException(String.format("Incorrect format for line [%s]", l));
return m;
}).collect(Collectors.toMap(m -> Version.fromString(m.group(1)), m -> Integer.parseInt(m.group(2))));
Integer existing = versions.putIfAbsent(release, id);
if (existing != null) {
if (existing.equals(id)) {
LOGGER.lifecycle("Version id [{}] for release [{}] already recorded", id, release);
return Optional.empty();
} else {
throw new IllegalArgumentException(
String.format(
"Release [%s] already recorded with version id [%s], cannot update to version [%s]",
release,
existing,
id
)
);
}View on GitHub (pinned to db6a809a66)
Solutions
- Inspect the record file at rootDir/INDEX_VERSIONS_RECORD and fix or remove any line not matching <major>.<minor>.<patch>,<id>.
- Strip trailing whitespace/blank lines and ensure consistent LF line endings.
- Re-derive the file from git history if a clean version is available.
Defensive patterns
Strategy: validation
Validate before calling
// Pre-validate the record file lines
private static final Pattern REC = Pattern.compile("(\\d+\\.\\d+\\.\\d+),(\\d+)");
static List<String> sanitize(List<String> lines) {
List<String> bad = lines.stream().filter(l -> !l.isBlank() && !REC.matcher(l).matches()).toList();
if (!bad.isEmpty()) throw new IllegalStateException("Bad record lines: " + bad);
return lines.stream().filter(l -> !l.isBlank()).toList();
} Prevention
- Never hand-edit the version record file; only the task should write it.
- Add a pre-commit hook that validates the record file format.
When it happens
Trigger: The record file (e.g. the INDEX_VERSIONS_RECORD file under rootDir) contains a non-conforming line — a trailing blank line with whitespace, a hand edit, a CRLF/encoding artefact, or a stale entry written by an older format.
Common situations: Someone manually edited the version record file; a merge introduced a stray line; the file was written with a different separator on another OS.
Related errors
- Release [%s] already recorded with version id [%s], cannot u
- Failed to read branches.json from {path}
- Duplicate version constants {v1}
- Cannot remove version [%s], it is referenced by CURRENT
- Invalid qualifier [{qualifier}] passed
AI-assisted analysis of elastic/elasticsearch@db6a809a66 (2026-08-12).
Data as JSON: /api/errors/5d80bca378f0a06a.
Report an issue: GitHub.