apache/iceberg · warning

Failed to delete path

Error message

Failed to delete path: {}

What it means

GCSFileIO.deleteFile logs a warning when the GCS storage client reports that the blob at the given path could not be deleted. Iceberg treats delete as best-effort here because there is no strict contract on delete failure, so no exception is thrown — the failure is only surfaced via LOG.warn. Downstream code may proceed assuming the file is gone when it is not.

Solutions

  1. Grant the service account storage.objects.delete (e.g. roles/storage.objectAdmin) on the bucket
  2. Check the path is a valid gs:// URI pointing at an existing blob (BlobId.fromGsUtilUri)
  3. Retry the delete; transient GCS errors can return false
  4. Enable GCS request logging to see the underlying error code for the failed delete

Example fix

// before
io.deleteFile("gs://bucket/table/data.parquet");
// after
if (!blobExists(io, "gs://bucket/table/data.parquet")) {
  LOG.info("skip delete, blob already gone");
} else {
  io.deleteFile("gs://bucket/table/data.parquet"); // verify in logs it succeeded
}
Defensive patterns

Strategy: validation

Validate before calling

if (path == null || !path.startsWith("gs://")) throw new IllegalArgumentException("not a gs:// path: " + path);

Prevention

When it happens

Trigger: Calling GCSFileIO.deleteFile(path) when the blob does not exist, the credentials lack storage.objects.delete permission, the bucket is in a different project, or a transient GCS error makes client.storage().delete(...) return false.

Common situations: Over-permissive assumptions about service-account rights when expiring old data files or orphan manifests; deleted-already blobs during concurrent commit/expiry; bucket lifecycle policies racing with Iceberg deleteFile.

Understand the failure class

Background: "failed to write file", "Could not save figure", "Error saving remote file" — file write failed: causes and fixes across languages and libraries — this error's family across 38 libraries.

Related errors


AI-assisted analysis of apache/iceberg@86d9c8fc54 (2026-09-12). Data as JSON: /api/errors/3f2e85db3d34935f. Report an issue: GitHub.

Appendix: source

Thrown at gcp/src/main/java/org/apache/iceberg/gcp/gcs/GCSFileIO.java:127

  @Override
  public InputFile newInputFile(String path, long length) {
    return GCSInputFile.fromLocation(path, length, clientForStoragePath(path), metrics);
  }

  @Override
  public OutputFile newOutputFile(String path) {
    return GCSOutputFile.fromLocation(path, clientForStoragePath(path), metrics);
  }

  @SuppressWarnings("resource")
  @Override
  public void deleteFile(String path) {
    // There is no specific contract about whether delete should fail
    // and other FileIO providers ignore failure.  Log the failure for
    // now as it is not a required operation for Iceberg.
    if (!clientForStoragePath(path).storage().delete(BlobId.fromGsUtilUri(path))) {
      LOG.warn("Failed to delete path: {}", path);
    }
  }

  @Override
  public Map<String, String> properties() {
    return properties.immutableMap();
  }

  public Storage client() {
    return client(ROOT_STORAGE_PREFIX);
  }

  @SuppressWarnings("resource")
  public Storage client(String storagePath) {
    return clientForStoragePath(storagePath).storage();
  }

  private PrefixedStorage clientForStoragePath(String storagePath) {

View on GitHub (pinned to 86d9c8fc54)