{"record":{"id":"6bd27a842b7b8ecd","repo":"apache/dolphinscheduler","slug":"the-path-should-not-be-empty","errorCode":null,"errorMessage":"The path should not be empty","messagePattern":"The path should not be empty","errorType":"exception","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/utils/FileUtils.java","lineNumber":298,"sourceCode":"                createDirectoryWithPermission(parent, permissions);\n            }\n\n            try {\n                Files.createDirectory(path);\n                Files.setPosixFilePermissions(path, permissions);\n            } catch (FileAlreadyExistsException fileAlreadyExistsException) {\n                log.error(\"The directory: {} already exists\", path);\n            }\n        }\n    }\n\n    public static String concatFilePath(String... paths) {\n        if (paths.length == 0) {\n            throw new IllegalArgumentException(\"At least one path should be provided\");\n        }\n        StringBuilder finalPath = new StringBuilder(paths[0]);\n        if (StringUtils.isEmpty(finalPath)) {\n            throw new IllegalArgumentException(\"The path should not be empty\");\n        }\n        String separator = File.separator;\n        for (int i = 1; i < paths.length; i++) {\n            String path = paths[i];\n            if (StringUtils.isEmpty(path)) {\n                throw new IllegalArgumentException(\"The path should not be empty\");\n            }\n            if (finalPath.toString().endsWith(separator) && path.startsWith(separator)) {\n                finalPath.append(path.substring(separator.length()));\n                continue;\n            }\n            if (!finalPath.toString().endsWith(separator) && !path.startsWith(separator)) {\n                finalPath.append(separator).append(path);\n                continue;\n            }\n            finalPath.append(path);\n        }\n        return finalPath.toString();","sourceCodeStart":280,"sourceCodeEnd":316,"githubUrl":"https://github.com/apache/dolphinscheduler/blob/02eac45a1b6676e639fcbfb4be2243de5771b05d/dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/utils/FileUtils.java#L280-L316","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","solutions":["Check StringUtils.isEmpty(baseDir) (or handle null explicitly) before calling concatFilePath and supply a valid default base path.","Fix the source of the empty value: set the missing configuration property or environment variable that should contain the base directory.","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.","Catch IllegalArgumentException at the call site if the empty base path is an expected, recoverable condition, and fall back to a default directory."],"exampleFix":"// before\nString dir = config.getResourcePath(); // may be null/empty\nString full = FileUtils.concatFilePath(dir, \"tenant\", \"data\");\n// after\nString dir = config.getResourcePath();\nif (StringUtils.isBlank(dir)) {\n    dir = \"/tmp/dolphinscheduler\"; // or throw a clearer config error\n}\nString full = FileUtils.concatFilePath(dir, \"tenant\", \"data\");","handlingStrategy":"validation","validationCode":"if (StringUtils.isEmpty(basePath)) {\n    throw new IllegalArgumentException(\"Base path for concatFilePath must be non-empty\");\n}\nString joined = FileUtils.concatFilePath(basePath, subPath);","typeGuard":null,"tryCatchPattern":"try {\n    path = FileUtils.concatFilePath(base, rest...);\n} catch (IllegalArgumentException e) {\n    path = defaultDir; // or rethrow with context\n}","preventionTips":["Validate configuration-provided directories with StringUtils.isNotBlank at startup, not at use site.","Never pass nullable variables directly as the first varargs segment; normalize to a default first.","Prefer java.nio.file.Paths.get(base, rest...) when empty segments should be tolerated instead of rejected."],"tags":["path-join","illegal-argument","empty-path"],"backgroundTag":"empty-required-field","analyzedSha":"02eac45a1b6676e639fcbfb4be2243de5771b05d","analyzedAt":"2026-09-06T17:43:00.555Z","contentChangedAt":"2026-09-06T17:43:00.555Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}