{"record":{"id":"78da5af1948daf8d","repo":"spring-projects/spring-boot","slug":"failed-to-add-to","errorCode":null,"errorMessage":"Failed to add {} to {}","messagePattern":"Failed to add (.+?) to (.+?)","errorType":"exception","errorClass":"GradleException","httpStatus":null,"severity":"error","filePath":"build-plugin/spring-boot-gradle-plugin/src/main/java/org/springframework/boot/gradle/tasks/bundling/BootZipCopyAction.java","lineNumber":222,"sourceCode":"\t\t\tthis.layerIndex = (BootZipCopyAction.this.layerResolver != null)\n\t\t\t\t\t? new LayersIndex(BootZipCopyAction.this.layerResolver.getLayers()) : null;\n\t\t}\n\n\t\tvoid process(FileCopyDetails details) {\n\t\t\tif (skipProcessing(details)) {\n\t\t\t\treturn;\n\t\t\t}\n\t\t\ttry {\n\t\t\t\twriteLoaderEntriesIfNecessary(details);\n\t\t\t\tif (details.isDirectory()) {\n\t\t\t\t\tprocessDirectory(details);\n\t\t\t\t}\n\t\t\t\telse {\n\t\t\t\t\tprocessFile(details);\n\t\t\t\t}\n\t\t\t}\n\t\t\tcatch (IOException ex) {\n\t\t\t\tthrow new GradleException(\"Failed to add \" + details + \" to \" + BootZipCopyAction.this.output, ex);\n\t\t\t}\n\t\t}\n\n\t\tprivate boolean skipProcessing(FileCopyDetails details) {\n\t\t\treturn BootZipCopyAction.this.exclusions.isSatisfiedBy(details)\n\t\t\t\t\t|| (this.writtenLoaderEntries != null && this.writtenLoaderEntries.isWrittenDirectory(details));\n\t\t}\n\n\t\tprivate void processDirectory(FileCopyDetails details) throws IOException {\n\t\t\tString name = details.getRelativePath().getPathString();\n\t\t\tZipArchiveEntry entry = new ZipArchiveEntry(name + '/');\n\t\t\tprepareEntry(entry, name, getTime(details), getDirMode(details));\n\t\t\tthis.out.putArchiveEntry(entry);\n\t\t\tthis.out.closeArchiveEntry();\n\t\t\tthis.writtenDirectories.add(name);\n\t\t}\n\n\t\tprivate void processFile(FileCopyDetails details) throws IOException {","sourceCodeStart":204,"sourceCodeEnd":240,"githubUrl":"https://github.com/spring-projects/spring-boot/blob/270dfe353fb830fd69b823a8a859287ff103854b/build-plugin/spring-boot-gradle-plugin/src/main/java/org/springframework/boot/gradle/tasks/bundling/BootZipCopyAction.java#L204-L240","documentation":"Thrown inside BootZipCopyAction's per-entry processing (the FileCopyDetails visitor) when writeLoaderEntriesIfNecessary, processDirectory, or processFile throws an IOException for a specific entry. Unlike error [8] (whole-archive failure), this names the individual entry (details) that failed, plus the target archive. The GradleException wraps the IOException with both the failing entry and the output.","triggerScenarios":"An IOException while writing a specific file or directory entry into the archive: e.g. the source file is unreadable, the zip entry stream fails, or writing the loader entries (spring-boot-loader classes) encounters an I/O error.","commonSituations":"A source file in the build output was deleted or locked between the copy spec resolution and the actual write (race with clean/rebuild). The spring-boot-loader JAR is corrupted or being modified during the build. Network filesystem I/O errors. The entry path is too long or contains characters the zip implementation rejects.","solutions":["Run 'gradle clean build' to ensure source files are fresh and not locked.","Examine the 'details' value in the message to identify which specific file/entry is failing and check its readability.","Ensure the spring-boot-loader dependency version is consistent with the plugin version (no version conflicts).","Move the build off a network filesystem if you see intermittent I/O errors.","Disable file-locking tools or antivirus for the build directory."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"// Verify all source files in the copy spec are readable before building.\ntasks.bootJar.inputs.files.each { f ->\n    if (f.exists() && !f.canRead()) {\n        throw new GradleException(\"Unreadable input: \" + f)\n    }\n}","typeGuard":null,"tryCatchPattern":"// Catch and inspect the failing entry from the message.\ntry {\n    bootJarTask.execute();\n} catch (GradleException ex) {\n    if (ex.getMessage()?.startsWith(\"Failed to add \")) {\n        // parse entry name, check readability, retry after clean\n    }\n    throw ex;\n}","preventionTips":["Run 'gradle clean build' to avoid stale/locked source files.","Ensure the spring-boot-loader version matches the plugin version.","Build on a local filesystem; avoid network mounts for the build directory."],"tags":["gradle","io","boot-archive","zip","filesystem","entry-processing"],"backgroundTag":null,"analyzedSha":"270dfe353fb830fd69b823a8a859287ff103854b","analyzedAt":"2026-08-11T19:42:06.541Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}