apache/beam · error · FileNotFoundException

The copy source does not exist.

Error message

The copy source does not exist.

What it means

In copy(), the source blob client is resolved and its existence verified before any copy is attempted. If the source blob does not exist, a FileNotFoundException with this message is thrown. Azure's server-side copy would otherwise fail asynchronously, so the library fails fast and explicitly.

Solutions

  1. Verify the source blob exists (az storage blob exists or FileSystems.match) before copying.
  2. Fix the source path spelling/casing.
  3. If using rename(), confirm the source was not already moved in a previous attempt (idempotency).
  4. Create the missing source (or recreate it) if it should exist.

Example fix

// before
FileSystems.copy(
    ImmutableList.of(FileSystems.matchNewResource("azfs://c/missing-src.txt", false)),
    ImmutableList.of(FileSystems.matchNewResource("azfs://c/dst.txt", false)));
// after
MatchResult src = FileSystems.match("azfs://c/src.txt");
if (src.status() == MatchResult.Status.OK) {
  FileSystems.copy(
      ImmutableList.of(src.metadata().get(0).resourceId()),
      ImmutableList.of(FileSystems.matchNewResource("azfs://c/dst.txt", false)));
}
Defensive patterns

Strategy: validation

Validate before calling

MatchResult src = FileSystems.match(srcPath);
if (src.status() != MatchResult.Status.OK || src.metadata().isEmpty()) {
  throw new FileNotFoundException("Copy source missing: " + srcPath);
}

Try / catch

try {
  FileSystems.copy(srcIds, dstIds);
} catch (FileNotFoundException e) {
  LOG.warn("copy source vanished: {}", e.getMessage());
  // retry with re-matched source or skip
}

Prevention

When it happens

Trigger: Calling FileSystems.copy(src, dest) where a source azfs path points to a nonexistent blob (or the source container does not exist).

Common situations: Rename/move operations (rename() calls copy() then delete()) where the source was already moved or deleted; incorrect source path casing; race with another process that removed the source.

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


AI-assisted analysis of apache/beam@12126d8942 (2026-09-13). Data as JSON: /api/errors/e72553be144293cd. Report an issue: GitHub.

Appendix: source

Thrown at sdks/java/io/azure/src/main/java/org/apache/beam/sdk/io/azure/blobstore/AzureBlobStoreFileSystem.java:338

      final AzfsResourceId destinationPath = destinationPathsIterator.next();
      copy(sourcePath, destinationPath);
    }
  }

  @VisibleForTesting
  void copy(AzfsResourceId sourcePath, AzfsResourceId destinationPath) throws IOException {
    checkArgument(
        sourcePath.getBlob() != null && destinationPath.getBlob() != null,
        "This method is intended to copy file-like resources, not directories.");

    // get source blob client
    BlobClient srcBlobClient =
        client
            .get()
            .getBlobContainerClient(sourcePath.getContainer())
            .getBlobClient(sourcePath.getBlob());
    if (!srcBlobClient.exists()) {
      throw new FileNotFoundException("The copy source does not exist.");
    }

    // get destination blob client
    BlobContainerClient destBlobContainerClient =
        client.get().getBlobContainerClient(destinationPath.getContainer());
    if (!destBlobContainerClient.exists()) {
      client.get().createBlobContainer(destinationPath.getContainer());
      LOG.info("Created a container called {}", destinationPath.getContainer());
    }
    BlobClient destBlobClient = destBlobContainerClient.getBlobClient(destinationPath.getBlob());

    destBlobClient.copyFromUrl(srcBlobClient.getBlobUrl() + generateSasToken());
  }

  @VisibleForTesting
  /** Generate an SAS Token if the user did not provide one through pipeline options */
  @SuppressWarnings("JavaUtilDate")
  String generateSasToken() throws IOException {

View on GitHub (pinned to 12126d8942)