{"record":{"id":"b869400a3cfd0c24","repo":"elastic/elasticsearch","slug":"building-s-didn-t-generate-expected-artifact-s","errorCode":null,"errorMessage":"Building %s didn't generate expected artifact [%s]. The working branch may be out-of-date - try merging in the latest upstream changes to the branch.","messagePattern":"Building (.+?) didn't generate expected artifact \\[(.+?)\\]\\. The working branch may be out-of-date - try merging in the latest upstream changes to the branch\\.","errorType":"exception","errorClass":"InvalidUserDataException","httpStatus":null,"severity":"error","filePath":"build-tools-internal/src/main/java/org/elasticsearch/gradle/internal/InternalDistributionBwcSetupPlugin.java","lineNumber":535,"sourceCode":"                } else {\n                    c.getOutputs().files(expectedOutputFile);\n                }\n                c.getOutputs().doNotCacheIf(\"BWC distribution caching is disabled for local builds\", task -> buildParams.getCi() == false);\n                c.getArgs().add(\"-p\");\n                c.getArgs().add(projectPath);\n                c.getArgs().add(assembleTaskName);\n                if (project.getGradle().getStartParameter().isBuildCacheEnabled()) {\n                    c.getArgs().add(\"--build-cache\");\n                }\n                File rootDir = project.getLayout().getSettingsDirectory().getAsFile();\n                c.doLast(new Action<Task>() {\n                    @Override\n                    public void execute(Task task) {\n                        if (expectedOutputFile.exists() == false) {\n                            Path relativeOutputPath = rootDir.toPath().relativize(expectedOutputFile.toPath());\n                            final String message = \"Building %s didn't generate expected artifact [%s]. The working branch may be \"\n                                + \"out-of-date - try merging in the latest upstream changes to the branch.\";\n                            throw new InvalidUserDataException(message.formatted(bwcVersion.get(), relativeOutputPath));\n                        }\n                    }\n                });\n            });\n            bwcTaskProvider.configure(t -> t.dependsOn(bwcTaskName));\n        }\n    }\n\n    private static void createDraBwcTask(\n        Project project,\n        String bwcTaskName,\n        String buildId,\n        String draBaseUrl,\n        Provider<Version> bwcVersion,\n        String projectName,\n        DistributionProjectArtifact projectArtifact,\n        String gradleClassifier,\n        String extension,","sourceCodeStart":517,"sourceCodeEnd":553,"githubUrl":"https://github.com/elastic/elasticsearch/blob/db6a809a667c081ca1dc7500389d26975573215f/build-tools-internal/src/main/java/org/elasticsearch/gradle/internal/InternalDistributionBwcSetupPlugin.java#L517-L553","documentation":"Thrown as InvalidUserDataException in the gradle-build BWC task's doLast when the expected output artifact (expectedOutputFile) doesn't exist after running the assemble task in the BWC checkout. The gradle-mode BWC path builds the previous version from source; if the build succeeded but didn't produce the expected archive name, the branch is likely out-of-date or the assemble task name is wrong.","triggerScenarios":"In the bwcSetupExtension.bwcTask configuration (line 505), after the forked Gradle build runs '-p <projectPath> <assembleTaskName>', the doLast at line 528 checks expectedOutputFile.exists(). If false, it formats the message with bwcVersion and the root-relative path and throws. Triggered when the BWC branch's build.gradle produces a differently-named artifact or the branch lacks the assemble task.","commonSituations":"The BWC branch hasn't been merged with the latest upstream changes that renamed/added the distribution artifact; the bwcVersion's checkout is stale; the assemble task name doesn't exist in that branch's build; expectedOutputFile path computed from current project layout doesn't match the older branch's output structure.","solutions":["Merge the latest upstream changes into the BWC branch and re-run — the message itself suggests this.","Verify the assembleTaskName exists in the BWC branch's build (e.g., ':distribution:archives:linux-tar:assemble' is valid for that version).","Check that expectedOutputFile's name matches what the BWC branch actually produces (version string, classifier, extension).","Run the BWC build manually in the checkout dir to see what artifact it generates: cd <checkout> && ./gradlew <assembleTaskName> and inspect build/distributions/."],"exampleFix":"# before: BWC branch lacks the new archive name\n# throws: Building 8.x didn't generate expected artifact [...]\n\ngit -C distribution/bwc/<ver> merge upstream/main\n./gradlew bwcTest","handlingStrategy":"validation","validationCode":"if (expectedOutputFile.exists() == false) {\n    // before throwing, check if the assemble task name is valid for this branch\n    System.err.println(\"Expected artifact missing: \" + expectedOutputFile);\n    System.err.println(\"Verify assemble task '\" + assembleTaskName + \"' exists in BWC branch\");\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Keep BWC branches merged with upstream to pick up artifact naming changes.","Verify the assemble task name exists in the BWC branch before relying on it.","Run the BWC build manually in the checkout to confirm expected output.","Use tests.bwc.mode=auto to fall back to DRA if gradle build fails."],"tags":["bwc","distribution","gradle","build-artifacts"],"backgroundTag":null,"analyzedSha":"db6a809a667c081ca1dc7500389d26975573215f","analyzedAt":"2026-08-12T01:39:14.192Z","schemaVersion":2},"datasetVersion":"2026-08-13T09:17:06.757Z"}