apache/beam · error · FileNotFoundException
The resource to delete does not exist.
Error message
The resource to delete does not exist.
What it means
When deleting a non-directory resource, delete() verifies the blob exists via blobClient.exists() and throws FileNotFoundException with this message if it does not. Azure's blob.delete() is idempotent, but Beam's filesystem contract treats deleting a nonexistent resource as an error, so the check happens before the delete call.
Solutions
- Match the paths first with FileSystems.match() and delete only resources that exist (make cleanup idempotent).
- Wrap the delete in try-catch for FileNotFoundException and treat it as success when cleanup semantics allow.
- Fix the blob key spelling/casing.
- Avoid deleting the same source list twice (e.g. after an earlier rename already moved it).
Example fix
// before
FileSystems.delete(ImmutableList.of(FileSystems.matchNewResource("azfs://c/gone.txt", false))); // throws
// after
MatchResult m = FileSystems.match("azfs://c/gone.txt");
if (m.status() == MatchResult.Status.OK && !m.metadata().isEmpty()) {
FileSystems.delete(m.metadata().stream().map(MatchResult.Metadata::resourceId).collect(ImmutableList.toImmutableList()));
} Defensive patterns
Strategy: try-catch
Validate before calling
MatchResult m = FileSystems.match(path);
if (m.status() == MatchResult.Status.OK) {
FileSystems.delete(m.metadata().stream().map(MatchResult.Metadata::resourceId).collect(ImmutableList.toImmutableList()));
} Try / catch
try {
FileSystems.delete(ids);
} catch (FileNotFoundException e) {
LOG.info("already deleted, ignoring: {}", e.getMessage());
} Prevention
- Make cleanup idempotent: match-then-delete or swallow FileNotFoundException.
- Never delete the same resource list twice (e.g. after rename already moved it).
- Be aware blob keys are case-sensitive when constructing delete paths.
When it happens
Trigger: Calling FileSystems.delete() (directly or via rename()'s delete step) with an azfs blob path that no longer exists in the container.
Common situations: rename() failing at the delete stage after copy succeeded because another process removed the source; double-cleanup code deleting the same paths twice; lifecycle policies deleting blobs before your cleanup job runs; case-sensitive key mismatch.
Understand the failure class
Background: "File not found" and ENOENT errors: why libraries can't find a file that should exist — this error's family across 50 libraries.
Related errors
- The copy source does not exist.
- The requested file doesn't exist.
- delete does not delete containers.
- This filename is already in use.
- Basepath %r must be an Azure Blob Storage path.
AI-assisted analysis of apache/beam@12126d8942 (2026-09-13).
Data as JSON: /api/errors/f6bb5a251bc2021e.
Report an issue: GitHub.
Appendix: source
Thrown at sdks/java/io/azure/src/main/java/org/apache/beam/sdk/io/azure/blobstore/AzureBlobStoreFileSystem.java:422
delete(srcResourceIds);
}
/** This method will delete a virtual folder or a blob, not a container. */
@Override
protected void delete(Collection<AzfsResourceId> resourceIds) throws IOException {
for (AzfsResourceId resourceId : resourceIds) {
if (resourceId.getBlob() == null) {
throw new IOException("delete does not delete containers.");
}
BlobContainerClient container =
client.get().getBlobContainerClient(resourceId.getContainer());
// deleting a blob that is not a directory
if (!resourceId.isDirectory()) {
BlobClient blob = container.getBlobClient(resourceId.getBlob());
if (!blob.exists()) {
throw new FileNotFoundException("The resource to delete does not exist.");
}
blob.delete();
}
// deleting a directory (not a container)
else {
PagedIterable<BlobItem> blobsInDirectory =
container.listBlobsByHierarchy(resourceId.getBlob());
blobsInDirectory.forEach(
blob -> {
String blobName = blob.getName();
container.getBlobClient(blobName).delete();
});
}
}
}
@OverrideView on GitHub (pinned to 12126d8942)