apache/beam · error · IllegalArgumentException

Could not determine the filename of the local artifact

Error message

Could not determine the filename of the local artifact {dependencyFilePath}

What it means

Thrown while copying each line of the Python requirements file into the dependencies volume: if a requirement line points to a local artifact (an existing path), Path.getFileName() returned null, meaning the path has no filename component (e.g. it is a root path). The launcher cannot determine what to name the copied artifact, so it aborts with this IllegalArgumentException.

Solutions

  1. Fix the requirements file so each local-artifact line points to an actual artifact file (e.g. a .whl or .tar.gz), not a directory or root path.
  2. Validate requirement lines before launching: each must be a normal file with a non-null filename.
  3. Remove blank or malformed lines from the requirements file.

Example fix

// before (requirements.txt)
/

// after (requirements.txt)
/artifacts/my_transform-1.0-py3-none-any.whl
Defensive patterns

Strategy: validation

Validate before calling

for (String line : java.nio.file.Files.readAllLines(requirementsFile)) {
  if (line.isBlank()) continue;
  Path p = Paths.get(line);
  if (java.nio.file.Files.exists(p)
      && (p.getFileName() == null || !java.nio.file.Files.isRegularFile(p)))
    throw new IllegalStateException("requirements entry must be a regular file: " + line);
}

Prevention

When it happens

Trigger: A line in the Python requirements file contains a local file path that exists but resolves to a path with a null filename — practically only when the path is a filesystem root (like "/" or "C:\\"), since getFileName() is non-null for normal file paths.

Common situations: A malformed requirements file line listing a directory root or an empty/odd path instead of an actual wheel or artifact file; hand-edited requirements files with trailing odd entries.

Understand the failure class

Background: "Invalid ... format", "must be in format X", "does not look like a ..." — invalid argument format errors across CLI tools and libraries — this error's family across 17 libraries.

Related errors


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

Appendix: source

Thrown at sdks/java/transform-service/launcher/src/main/java/org/apache/beam/sdk/transformservice/launcher/TransformServiceLauncher.java:165

      File file = updatedRequirementsFilePath.toFile();
      if (!file.createNewFile()) {
        throw new IOException(
            "Could not create the new requirements file " + updatedRequirementsFilePath);
      }

      // Updating dependencies.
      if (pythonRequirementsFile != null) {
        Path requirementsFilePath = Paths.get(pythonRequirementsFile);
        List<String> updatedLines = new ArrayList<>();

        try (Stream<String> lines = java.nio.file.Files.lines(requirementsFilePath)) {
          lines.forEachOrdered(
              line -> {
                Path dependencyFilePath = Paths.get(line);
                if (java.nio.file.Files.exists(dependencyFilePath)) {
                  Path fileName = dependencyFilePath.getFileName();
                  if (fileName == null) {
                    throw new IllegalArgumentException(
                        "Could not determine the filename of the local artifact "
                            + dependencyFilePath);
                  }
                  try {
                    java.nio.file.Files.copy(
                        dependencyFilePath,
                        Paths.get(dependenciesDir.toString(), fileName.toString()));
                  } catch (IOException e) {
                    throw new RuntimeException(e);
                  }
                  updatedLines.add(fileName.toString());
                } else {
                  updatedLines.add(line);
                }
              });
        }

        try (BufferedWriter writer =

View on GitHub (pinned to 12126d8942)