{"record":{"id":"fe496d6b0a172a36","repo":"elastic/elasticsearch","slug":"failed-to-write-marker-file","errorCode":null,"errorMessage":"Failed to write marker file","messagePattern":"Failed to write marker file","errorType":"exception","errorClass":"RuntimeException","httpStatus":null,"severity":"error","filePath":"build-tools-internal/src/main/java/org/elasticsearch/gradle/internal/docker/DockerBuildTask.java","lineNumber":323,"sourceCode":"                        // (23.0+) that may create manifest lists even for single-platform builds\n                        // when BuildKit is enabled.\n                        spec.args(\"--load\");\n                    }\n                }\n            });\n\n            // Fetch the Docker image's hash, and write it to desk as the task's output. Doing this allows us\n            // to do proper up-to-date checks in Gradle.\n            try {\n                // multi-platform image builds do not end up in local registry, so we need to pull the just build image\n                // first to get the checksum and also serves as a test for the image being pushed correctly\n                if (parameters.getPlatforms().get().size() > 1 && parameters.getPush().getOrElse(false)) {\n                    pullBaseImage(tags.get(0));\n                }\n                final String checksum = getImageChecksum(tags.get(0));\n                Files.writeString(parameters.getMarkerFile().getAsFile().get().toPath(), checksum + \"\\n\");\n            } catch (IOException e) {\n                throw new RuntimeException(\"Failed to write marker file\", e);\n            }\n        }\n\n        /**\n         * Resolves an {@code oci-layout://} build context value to a digest-qualified reference.\n         * Buildx resolves OCI layout contexts by tag or digest within the layout; the tag recorded\n         * in the layout's index is not always what buildx looks up by default, so pinning the\n         * manifest digest from {@code index.json} is the most robust way to reference the\n         * (single-image) layouts we export.\n         */\n        private static String resolveBuildContext(String value) {\n            String prefix = \"oci-layout://\";\n            if (value.startsWith(prefix) == false || value.contains(\"@\")) {\n                return value;\n            }\n            Path indexJson = Path.of(value.substring(prefix.length()), \"index.json\");\n            try {\n                // The exported layouts contain a single manifest, so plucking the first digest is","sourceCodeStart":305,"sourceCodeEnd":341,"githubUrl":"https://github.com/elastic/elasticsearch/blob/db6a809a667c081ca1dc7500389d26975573215f/build-tools-internal/src/main/java/org/elasticsearch/gradle/internal/docker/DockerBuildTask.java#L305-L341","documentation":"Thrown by DockerBuildAction.execute() when writing the computed image checksum to the task's marker file fails with an IOException. After building the image (and optionally pulling it for multi-platform builds), the task computes a checksum and writes `<checksum>\\n` to the marker file so Gradle can do up-to-date checks; an IOException here is wrapped in a RuntimeException. The marker file is the task's declared output, so failing to write it fails the whole task.","triggerScenarios":"Files.writeString(markerFile, checksum) throws IOException. Causes: the marker file's parent directory does not exist or is not writable; the output path was deleted mid-build; disk full or filesystem read-only; the path points to an invalid location; security manager / permissions deny the write.","commonSituations":"A `clean` or concurrent build removed the build output directory between task start and the write; the task's markerFile property is misconfigured to point at a read-only or non-existent parent; running on a CI ephemeral worker with a full tmpfs; permissions issue from running as a different user than the build dir owner.","solutions":["Check the marker file's parent directory exists and is writable by the build user.","Ensure no concurrent build or `clean` is removing the output dir mid-task.","Free disk space / verify the filesystem is writable.","If the markerFile property was overridden in build config, point it at a valid writable path inside the project build dir."],"exampleFix":null,"handlingStrategy":"validation","validationCode":"// Before building, assert the marker file's parent exists and is writable:\n// Path parent = markerFile.toPath().getParent();\n// if (!Files.isDirectory(parent) || !Files.isWritable(parent)) fail(\"bad marker dir\");","typeGuard":null,"tryCatchPattern":"// try { Files.writeString(markerPath, checksum + \"\\n\"); }\n// catch (IOException e) { throw new RuntimeException(\"Failed to write marker file\", e); }","preventionTips":["Don't run `clean` concurrently with the Docker build task.","Keep the marker file path inside the project build dir on a writable filesystem.","Ensure adequate free disk space on CI workers."],"tags":["docker","build","io","filesystem"],"analyzedSha":"db6a809a667c081ca1dc7500389d26975573215f","analyzedAt":"2026-08-12T01:39:14.192Z","schemaVersion":2},"datasetVersion":"2026-08-12T08:17:17.861Z"}