{"record":{"id":"0d3aeeec00088948","repo":"apache/iceberg","slug":"failed-to-delete-object-at-path","errorCode":null,"errorMessage":"Failed to delete object at path {}","messagePattern":"Failed to delete object at path (.+?)","errorType":"console","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"aws/src/main/java/org/apache/iceberg/aws/s3/S3FileIO.java","lineNumber":257,"sourceCode":"      }\n\n      // Delete the remainder\n      for (Map.Entry<String, Collection<String>> bucketToObjectsEntry :\n          bucketToObjects.asMap().entrySet()) {\n        String bucket = bucketToObjectsEntry.getKey();\n        Collection<String> keys = bucketToObjectsEntry.getValue();\n        Future<List<String>> deletionTask =\n            executorService()\n                .submit(() -> deleteBatch(clientForStoragePath(\"s3://\" + bucket), bucket, keys));\n        deletionTasks.add(deletionTask);\n      }\n\n      int totalFailedDeletions = 0;\n\n      for (Future<List<String>> deletionTask : deletionTasks) {\n        try {\n          List<String> failedDeletions = deletionTask.get();\n          failedDeletions.forEach(path -> LOG.warn(\"Failed to delete object at path {}\", path));\n          totalFailedDeletions += failedDeletions.size();\n        } catch (ExecutionException e) {\n          LOG.warn(\"Caught unexpected exception during batch deletion: \", e.getCause());\n        } catch (InterruptedException e) {\n          Thread.currentThread().interrupt();\n          deletionTasks.stream().filter(task -> !task.isDone()).forEach(task -> task.cancel(true));\n          throw new RuntimeException(\"Interrupted when waiting for deletions to complete\", e);\n        }\n      }\n\n      if (totalFailedDeletions > 0) {\n        throw new BulkDeletionFailureException(totalFailedDeletions);\n      }\n    }\n  }\n\n  private void tagFileToDelete(PrefixedS3Client client, String path, Set<Tag> deleteTags)\n      throws S3Exception {","sourceCodeStart":239,"sourceCodeEnd":275,"githubUrl":"https://github.com/apache/iceberg/blob/86d9c8fc543e7c56c9f624eb725f76c9baff9570/aws/src/main/java/org/apache/iceberg/aws/s3/S3FileIO.java#L239-L275","documentation":"After batch deleteObject calls complete, S3FileIO.deleteFiles() collects the keys that S3 reported as failed and logs one warning per failed path. This means the object was NOT deleted despite the batch call succeeding at the transport level. Deletion then continues and the total failure count is tracked.","triggerScenarios":"deleteFiles() issued for keys that do not exist in some edge configurations, or S3 batch delete responses containing per-key errors (e.g. access denied, lifecycle lock, object held by Object Lock / legal hold).","commonSituations":"Objects under S3 Object Lock retention; IAM denies for specific prefixes; eventual-consistency edge cases in legacy setups; wrong bucket/prefix in file paths.","solutions":["Inspect the logged path and verify IAM allows s3:DeleteObject on that key's prefix","Check for S3 Object Lock, legal hold, or retention settings on the object","Confirm the path/bucket is correct — typos produce un-deletable keys","Retry the deletion; transient errors may succeed on re-run"],"exampleFix":null,"handlingStrategy":"validation","validationCode":"// before deleteFiles, confirm keys exist and are deletable\nHeadResponse h = s3Client.headObject(b -> b.bucket(bucket).key(key)); // check Object Lock / retention headers","typeGuard":null,"tryCatchPattern":"try { io.deleteFiles(paths); } catch (RuntimeException e) { LOG.error(\"deleteFiles aborted\", e); } // individual failures are warnings only","preventionTips":["Check S3 Object Lock / legal hold status before deleting","Validate path prefixes against the actual bucket layout","Collect and re-run the failed deletion paths reported in logs"],"tags":["aws","s3","batch-delete","logging"],"backgroundTag":"api-error-response","analyzedSha":"86d9c8fc543e7c56c9f624eb725f76c9baff9570","analyzedAt":"2026-09-12T00:46:39.097Z","contentChangedAt":"2026-09-12T00:46:39.097Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}