{"record":{"id":"1d2a2c5175109686","repo":"elastic/elasticsearch","slug":"version-already-exists-in-transportversions-csv","errorCode":null,"errorMessage":"Version {} already exists in TransportVersions.csv with transport version ID {}, but expected {}","messagePattern":"Version (.+?) already exists in TransportVersions\\.csv with transport version ID (.+?), but expected (.+?)","errorType":"exception","errorClass":"RuntimeException","httpStatus":null,"severity":"error","filePath":"build-tools-internal/src/main/java/org/elasticsearch/gradle/internal/transport/UpdateTransportVersionsCSVTask.java","lineNumber":55,"sourceCode":"\n    @TaskAction\n    public void run() throws IOException {\n        Version stackVersion = Version.fromString(getStackVersion().get());\n        String upperBoundName = getUpperBoundName(stackVersion);\n        TransportVersionResourcesService resources = getResourceService().get();\n        TransportVersionUpperBound upperBound = resources.getUpperBoundFromGitBase(upperBoundName);\n\n        if (upperBound == null) {\n            throw new RuntimeException(\"Missing upper bound \" + upperBoundName + \" for stack version \" + stackVersion);\n        }\n\n        int expectedTransportVersionId = upperBound.definitionId().complete();\n\n        // Check if this version is already in the CSV file (idempotency check)\n        Integer existingTransportVersionId = getExistingTransportVersionId(stackVersion);\n        if (existingTransportVersionId != null) {\n            if (existingTransportVersionId != expectedTransportVersionId) {\n                throw new RuntimeException(\n                    \"Version \"\n                        + stackVersion\n                        + \" already exists in TransportVersions.csv with transport version ID \"\n                        + existingTransportVersionId\n                        + \", but expected \"\n                        + expectedTransportVersionId\n                );\n            }\n            getLogger().lifecycle(\n                \"Version {} already exists in TransportVersions.csv with correct transport version ID, skipping\",\n                stackVersion\n            );\n            return;\n        }\n\n        addTransportVersionRecord(stackVersion, expectedTransportVersionId);\n    }\n","sourceCodeStart":37,"sourceCodeEnd":73,"githubUrl":"https://github.com/elastic/elasticsearch/blob/db6a809a667c081ca1dc7500389d26975573215f/build-tools-internal/src/main/java/org/elasticsearch/gradle/internal/transport/UpdateTransportVersionsCSVTask.java#L37-L73","documentation":"Thrown by the UpdateTransportVersionsCSVTask Gradle task when regenerating TransportVersions.csv. The task recomputes the expected transport version ID for a stack version from its declared upper bound, then checks the existing CSV row for idempotency. If the row is present but its recorded ID disagrees with the freshly computed one, the task aborts rather than silently rewriting committed data.","triggerScenarios":"Running './gradlew generateTransportVersion' (or any task wiring UpdateTransportVersionsCSVTask) after the upper-bound definition for an already-released stack version was edited, so the same stack version string now maps to a different definitionId().complete(). Also when a CSV row was hand-edited or cherry-picked from a branch with a different ID assignment.","commonSituations":"Backporting a transport-version change across branches where the ID allocation diverged; rebasing a PR whose upper-bounds file conflicts with a merged change; manually editing TransportVersions.csv; switching between feature branches that each allocated a different ID for the same version name.","solutions":["Inspect the named upper bound file for the stack version and confirm definitionId().complete() matches the value the task expects; revert any unintended edits to that upper bound.","If the CSV row is genuinely stale, delete the offending row from TransportVersions.csv and rerun './gradlew generateTransportVersion' to regenerate it from the current upper bound.","If the upper bound itself was changed intentionally, coordinate with the transport-version owner — a released version's ID must never change, so the fix is usually to restore the original upper bound and allocate a new version for the new wire change instead."],"exampleFix":"// before: upper bound edited so stackVersion 9.0.0 now yields id 1234, but CSV still says 1230\n// after: revert the upper bound file, then add a NEW upper bound for the new wire change instead\n//   git checkout -- <upper-bound-file>\n//   ./gradlew generateTransportVersion","handlingStrategy":"validation","validationCode":"// Before running generateTransportVersion, confirm the upper bound for the stack version is committed and unchanged:\n// git diff --name-only -- <upper-bound-path>   (should be empty unless you intend a new allocation)\n// Run the task only on a clean tree matching the intended ID assignment.","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Never mutate an upper bound for an already-released stack version; allocate a new transport version instead.","Run './gradlew generateTransportVersion' on a clean checkout so the CSV and upper bounds stay consistent.","Treat TransportVersions.csv and upper-bound files as atomic in PRs — never edit one without the other."],"tags":["build","gradle","transport-version","versioning","idempotency"],"backgroundTag":null,"analyzedSha":"db6a809a667c081ca1dc7500389d26975573215f","analyzedAt":"2026-08-12T01:39:14.192Z","schemaVersion":2},"datasetVersion":"2026-08-13T09:17:06.757Z"}