{"record":{"id":"8bfd93f4f985abc5","repo":"elastic/elasticsearch","slug":"unknown-version-type-key","errorCode":null,"errorMessage":"Unknown version type {key}","messagePattern":"Unknown version type (.+?)","errorType":"validation","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"build-tools-internal/src/main/java/org/elasticsearch/gradle/internal/release/TagVersionsTask.java","lineNumber":70,"sourceCode":"    }\n\n    @TaskAction\n    public void executeTask() throws IOException {\n        if (releaseVersion == null) {\n            throw new IllegalArgumentException(\"Release version not specified\");\n        }\n        if (tagVersions.isEmpty()) {\n            throw new IllegalArgumentException(\"No version tags specified\");\n        }\n\n        LOGGER.lifecycle(\"Tagging version {} component ids\", releaseVersion);\n\n        var versions = expandV7Version(tagVersions);\n\n        for (var v : versions.entrySet()) {\n            Path recordFile = switch (v.getKey()) {\n                case INDEX_VERSION_TYPE -> rootDir.resolve(INDEX_VERSIONS_RECORD);\n                default -> throw new IllegalArgumentException(\"Unknown version type \" + v.getKey());\n            };\n\n            LOGGER.lifecycle(\"Adding version record for {} to [{}]: [{},{}]\", v.getKey(), recordFile, releaseVersion, v.getValue());\n\n            Path file = rootDir.resolve(recordFile);\n            List<String> versionRecords = Files.readAllLines(file);\n            var modified = addVersionRecord(versionRecords, releaseVersion, v.getValue());\n            if (modified.isPresent()) {\n                Files.write(\n                    file,\n                    modified.get(),\n                    StandardOpenOption.CREATE,\n                    StandardOpenOption.WRITE,\n                    StandardOpenOption.TRUNCATE_EXISTING\n                );\n            }\n        }\n    }","sourceCodeStart":52,"sourceCodeEnd":88,"githubUrl":"https://github.com/elastic/elasticsearch/blob/db6a809a667c081ca1dc7500389d26975573215f/build-tools-internal/src/main/java/org/elasticsearch/gradle/internal/release/TagVersionsTask.java#L52-L88","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","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."],"exampleFix":"// before\n./gradlew tagVersions --release=8.10.0 --tag-version=Foo:42\n\n// after\n./gradlew tagVersions --release=8.10.0 --tag-version=Index:42","handlingStrategy":"validation","validationCode":"// Allow-list the VersionType prefixes before invoking the task\nprivate static final Set<String> ALLOWED_TYPES = Set.of(\"Index\", \"Version\");\nstatic void checkType(String raw) {\n    String prefix = raw.split(\":\", 2)[0];\n    if (!ALLOWED_TYPES.contains(prefix)) {\n        throw new IllegalArgumentException(\"Unknown VersionType \" + prefix + \"; allowed \" + ALLOWED_TYPES);\n    }\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["When adding a new VersionType, update the switch AND this allow-list together.","Document valid prefixes in the task --help text."],"tags":["release-tooling","gradle-task","version-type","precondition"],"analyzedSha":"db6a809a667c081ca1dc7500389d26975573215f","analyzedAt":"2026-08-12T01:39:14.192Z","schemaVersion":2},"datasetVersion":"2026-08-12T06:17:24.410Z"}