elastic/elasticsearch · error · IllegalArgumentException
Unknown version type {key}
Error message
Unknown version type {key} What it means
Thrown inside the switch in TagVersionsTask.executeTask() when expandV7Version() returns a map whose key is not the expected INDEX_VERSION_TYPE constant. The switch only handles INDEX_VERSION_TYPE and throws for any other key, signalling an unrecognised VersionType identifier.
Source
Thrown at build-tools-internal/src/main/java/org/elasticsearch/gradle/internal/release/TagVersionsTask.java:70
}
@TaskAction
public void executeTask() throws IOException {
if (releaseVersion == null) {
throw new IllegalArgumentException("Release version not specified");
}
if (tagVersions.isEmpty()) {
throw new IllegalArgumentException("No version tags specified");
}
LOGGER.lifecycle("Tagging version {} component ids", releaseVersion);
var versions = expandV7Version(tagVersions);
for (var v : versions.entrySet()) {
Path recordFile = switch (v.getKey()) {
case INDEX_VERSION_TYPE -> rootDir.resolve(INDEX_VERSIONS_RECORD);
default -> throw new IllegalArgumentException("Unknown version type " + v.getKey());
};
LOGGER.lifecycle("Adding version record for {} to [{}]: [{},{}]", v.getKey(), recordFile, releaseVersion, v.getValue());
Path file = rootDir.resolve(recordFile);
List<String> versionRecords = Files.readAllLines(file);
var modified = addVersionRecord(versionRecords, releaseVersion, v.getValue());
if (modified.isPresent()) {
Files.write(
file,
modified.get(),
StandardOpenOption.CREATE,
StandardOpenOption.WRITE,
StandardOpenOption.TRUNCATE_EXISTING
);
}
}
}View on GitHub (pinned to db6a809a66)
Solutions
- Use a recognised VersionType prefix — currently only Index (and legacy Version, which maps to Index) is valid.
- If introducing a new version type, add a case branch resolving the correct record file alongside INDEX_VERSIONS_RECORD.
Example fix
// before ./gradlew tagVersions --release=8.10.0 --tag-version=Foo:42 // after ./gradlew tagVersions --release=8.10.0 --tag-version=Index:42
Defensive patterns
Strategy: validation
Validate before calling
// Allow-list the VersionType prefixes before invoking the task
private static final Set<String> ALLOWED_TYPES = Set.of("Index", "Version");
static void checkType(String raw) {
String prefix = raw.split(":", 2)[0];
if (!ALLOWED_TYPES.contains(prefix)) {
throw new IllegalArgumentException("Unknown VersionType " + prefix + "; allowed " + ALLOWED_TYPES);
}
} Prevention
- When adding a new VersionType, update the switch AND this allow-list together.
- Document valid prefixes in the task --help text.
When it happens
Trigger: Passing --tag-version with a VersionType prefix other than "Index" (and the legacy "Version" which expandV7Version maps to INDEX_VERSION_TYPE), e.g. --tag-version=Foo:42, or adding a new VersionType constant without extending this switch.
Common situations: A new version-tracking record type is introduced in the codebase but the switch in TagVersionsTask was not updated; a typo in the type prefix on the command line.
Related errors
- Release version not specified
- No version tags specified
- Expected branch and version in format <branch>:<version>
- At least one of add-branch, remove-branch or update-branch m
- No versions to add or remove specified
AI-assisted analysis of elastic/elasticsearch@db6a809a66 (2026-08-12).
Data as JSON: /api/errors/8bfd93f4f985abc5.
Report an issue: GitHub.