apache/dolphinscheduler · error · IllegalArgumentException

The path should not be empty

Error message

The path should not be empty

What it means

concatFilePath joins path fragments into a single filesystem path using the platform separator. It throws this IllegalArgumentException when the first path argument (paths[0]) is null or empty, because a joined path with no base segment is meaningless. This is an eager fail-fast guard rather than silently producing a broken path.

Source

Thrown at dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/utils/FileUtils.java:298

                createDirectoryWithPermission(parent, permissions);
            }

            try {
                Files.createDirectory(path);
                Files.setPosixFilePermissions(path, permissions);
            } catch (FileAlreadyExistsException fileAlreadyExistsException) {
                log.error("The directory: {} already exists", path);
            }
        }
    }

    public static String concatFilePath(String... paths) {
        if (paths.length == 0) {
            throw new IllegalArgumentException("At least one path should be provided");
        }
        StringBuilder finalPath = new StringBuilder(paths[0]);
        if (StringUtils.isEmpty(finalPath)) {
            throw new IllegalArgumentException("The path should not be empty");
        }
        String separator = File.separator;
        for (int i = 1; i < paths.length; i++) {
            String path = paths[i];
            if (StringUtils.isEmpty(path)) {
                throw new IllegalArgumentException("The path should not be empty");
            }
            if (finalPath.toString().endsWith(separator) && path.startsWith(separator)) {
                finalPath.append(path.substring(separator.length()));
                continue;
            }
            if (!finalPath.toString().endsWith(separator) && !path.startsWith(separator)) {
                finalPath.append(separator).append(path);
                continue;
            }
            finalPath.append(path);
        }
        return finalPath.toString();

View on GitHub (pinned to 02eac45a1b)

Solutions

  1. Check StringUtils.isEmpty(baseDir) (or handle null explicitly) before calling concatFilePath and supply a valid default base path.
  2. Fix the source of the empty value: set the missing configuration property or environment variable that should contain the base directory.
  3. If an empty first segment is legitimately possible, filter it out of the array before joining: paths = Arrays.stream(paths).filter(StringUtils::isNotEmpty).toArray(String[]::new), then re-check non-empty.
  4. Catch IllegalArgumentException at the call site if the empty base path is an expected, recoverable condition, and fall back to a default directory.

Example fix

// before
String dir = config.getResourcePath(); // may be null/empty
String full = FileUtils.concatFilePath(dir, "tenant", "data");
// after
String dir = config.getResourcePath();
if (StringUtils.isBlank(dir)) {
    dir = "/tmp/dolphinscheduler"; // or throw a clearer config error
}
String full = FileUtils.concatFilePath(dir, "tenant", "data");
Defensive patterns

Strategy: validation

Validate before calling

if (StringUtils.isEmpty(basePath)) {
    throw new IllegalArgumentException("Base path for concatFilePath must be non-empty");
}
String joined = FileUtils.concatFilePath(basePath, subPath);

Try / catch

try {
    path = FileUtils.concatFilePath(base, rest...);
} catch (IllegalArgumentException e) {
    path = defaultDir; // or rethrow with context
}

Prevention

When it happens

Trigger: Calling FileUtils.concatFilePath(null, ...) or concatFilePath("", "subdir", "file.txt") — i.e. the first element of the varargs array is null or the empty string. With varargs this commonly happens when a variable holding the base directory is null/unset and the compiler cannot catch it.

Common situations: A config property for a base directory (resource storage path, tenant dir, task working dir) is missing or empty; a method parameter defaulted to null is passed straight through as the first segment; code refactored to varargs where an empty first segment used to be tolerated.

Understand the failure class

Background: "must not be empty", "cannot be empty" — required-field validation errors across open-source libraries — this error's family across 41 libraries.

Related errors


AI-assisted analysis of apache/dolphinscheduler@02eac45a1b (2026-09-06). Data as JSON: /api/errors/6bd27a842b7b8ecd. Report an issue: GitHub.