{"record":{"id":"24e3ec5b8d7d7a18","repo":"jenkinsci/jenkins","slug":"failed-to-delete-0-24e3ec","errorCode":null,"errorMessage":"Failed to delete {0}","messagePattern":"Failed to delete (.+?)","errorType":"exception","errorClass":"IOException","httpStatus":null,"severity":"error","filePath":"core/src/main/java/hudson/model/AbstractItem.java","lineNumber":811,"sourceCode":"        try {\n            // if a build is in progress. Cancel it.\n            if (responsibleForAbortingBuilds || ownsRegistration) {\n                ItemDeletion.cancelBuildsInProgress(this);\n            }\n            if (this instanceof ItemGroup) {\n                // delete individual items first\n                // (disregard whether they would be deletable in isolation)\n                // JENKINS-34939: do not hold the monitor on this folder while deleting them\n                // (thus we cannot do this inside performDelete)\n                try (ACLContext oldContext = ACL.as2(ACL.SYSTEM2)) {\n                    for (Item i : ((ItemGroup<?>) this).getItems(TopLevelItem.class::isInstance)) {\n                        try {\n                            i.delete();\n                        } catch (AbortException e) {\n                            throw (AbortException) new AbortException(\n                                    \"Failed to delete \" + i.getFullDisplayName() + \" : \" + e.getMessage()).initCause(e);\n                        } catch (IOException e) {\n                            throw new IOException(\"Failed to delete \" + i.getFullDisplayName(), e);\n                        }\n                    }\n                }\n            }\n            synchronized (this) { // could just make performDelete synchronized but overriders might not honor that\n                performDelete();\n            } // JENKINS-19446: leave synch block, but JENKINS-22001: still notify synchronously\n        } finally {\n            if (ownsRegistration) {\n                ItemDeletion.deregister(this);\n            }\n        }\n        SaveableListener.fireOnDeleted(this, getConfigFile());\n        getParent().onDeleted(AbstractItem.this);\n        Jenkins.get().rebuildDependencyGraphAsync();\n    }\n\n    /**","sourceCodeStart":793,"sourceCodeEnd":829,"githubUrl":"https://github.com/jenkinsci/jenkins/blob/2e228ff40b14dbc8b14ffbc6edf0e4383cf744fc/core/src/main/java/hudson/model/AbstractItem.java#L793-L829","documentation":"Thrown during folder/group deletion when iterating child items: if i.delete() throws AbortException, it is re-thrown as a new AbortException with 'Failed to delete <child> : <cause>'; if it throws a plain IOException, it is wrapped as IOException('Failed to delete <child>', cause). This surfaces which child item failed during a recursive folder delete.","triggerScenarios":"delete() is called on an ItemGroup; the loop over getItems(TopLevelItem.class::isInstance) calls i.delete() on each child; a child's performDelete or its own delete throws.","commonSituations":"A child job has a running build that cannot be cancelled; a child item's config or workspace is locked/on a read-only filesystem; a plugin's DeleteListener or performDelete override throws; permission issues on a specific child.","solutions":["Read the cause exception to identify which child failed and why (the child name is in the message)","Cancel builds on or fix the specific child item that failed, then retry the folder delete","Check DELETE permission on all children (the loop runs as SYSTEM via ACLContext, but plugin guards may still fail)","If a plugin's performDelete is the culprit, update or disable that plugin"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"try {\n    folder.delete();\n} catch (IOException | AbortException e) {\n    if (e.getMessage().startsWith(\"Failed to delete\")) {\n        // a child item failed; inspect cause and fix the specific child, then retry\n    }\n    throw e;\n}","preventionTips":["Before deleting a folder, cancel builds on all children and verify no locks","Ensure all children are deletable (permissions, no running builds)","Inspect the wrapped cause to find the failing child and plugin"],"tags":["item","delete","folder","recursive","ioexception","child"],"backgroundTag":null,"analyzedSha":"2e228ff40b14dbc8b14ffbc6edf0e4383cf744fc","analyzedAt":"2026-08-14T07:07:15.274Z","schemaVersion":2},"datasetVersion":"2026-08-14T10:17:34.591Z"}