{"record":{"id":"955540b0a5949e12","repo":"apache/flink","slug":"can-not-create-a-path-from-an-empty-string","errorCode":null,"errorMessage":"Can not create a Path from an empty string","messagePattern":"Can not create a Path from an empty string","errorType":"validation","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"flink-core/src/main/java/org/apache/flink/core/fs/Path.java","lineNumber":163,"sourceCode":"\n        final URI resolved = parentUri.resolve(child.uri);\n        initialize(resolved.getScheme(), resolved.getAuthority(), resolved.getPath());\n    }\n\n    /**\n     * Checks if the provided path string is either null or has zero length and throws a {@link\n     * IllegalArgumentException} if any of the two conditions apply.\n     *\n     * @param path the path string to be checked\n     * @return The checked path.\n     */\n    private String checkPathArg(String path) {\n        // disallow construction of a Path from an empty string\n        if (path == null) {\n            throw new IllegalArgumentException(\"Can not create a Path from a null string\");\n        }\n        if (path.length() == 0) {\n            throw new IllegalArgumentException(\"Can not create a Path from an empty string\");\n        }\n        return path;\n    }\n\n    /**\n     * Construct a path from a String. Path strings are URIs, but with unescaped elements and some\n     * additional normalization.\n     *\n     * @param pathString the string to construct a path from\n     */\n    public Path(String pathString) {\n        pathString = checkPathArg(pathString);\n\n        // We can't use 'new URI(String)' directly, since it assumes things are\n        // escaped, which we don't require of Paths.\n\n        // add a slash in front of paths with Windows drive letters\n        if (hasWindowsDrive(pathString, false)) {","sourceCodeStart":145,"sourceCodeEnd":181,"githubUrl":"https://github.com/apache/flink/blob/2f3c205e9266cb30240eb7f4fdab15cad629a70f/flink-core/src/main/java/org/apache/flink/core/fs/Path.java#L145-L181","documentation":"Thrown by Path's private checkPathArg when constructing a Path from a String whose length is zero. The Path constructor treats path strings as URIs and an empty URI has no meaning, so it is rejected before any parsing. A separate message exists for null inputs.","triggerScenarios":"Calling `new Path(\"\")` or any Path factory (Path(String), Path(URI) indirectly) that resolves to an empty string. Also reached when a config option, connector path, or checkpoint/savepoint location string trims to empty and is passed into a Path.","commonSituations":"A misconfigured `state.checkpoints.dir` or `execution.checkpointing.savepoint` set to an empty value; a dynamically-built path whose variable substitution failed (e.g. ENV var unset yielding \"\"); a unit test passing an empty literal.","solutions":["Validate the path string is non-empty before constructing the Path: `if (pathStr == null || pathStr.isEmpty()) throw ...`.","Check the config option supplying the path (e.g. `state.checkpoints.dir`, `fs.default-scheme`) and ensure it has a real value.","If the path may legitimately be unset, supply a sensible default or skip the operation rather than passing \"\".","Add a startup assertion in your job main() that resolves all configured paths to non-empty strings."],"exampleFix":"// before\nPath p = new Path(config.get(\"output.dir\"));\n\n// after\nString dir = config.get(\"output.dir\");\nif (dir == null || dir.isEmpty()) {\n    throw new IllegalArgumentException(\"output.dir must be configured\");\n}\nPath p = new Path(dir);","handlingStrategy":"validation","validationCode":"private static Path safePath(String s) {\n    if (s == null) throw new IllegalArgumentException(\"path is null\");\n    String trimmed = s.trim();\n    if (trimmed.isEmpty()) throw new IllegalArgumentException(\"path is empty\");\n    return new Path(trimmed);\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Centralize all Path construction in one helper that rejects null/empty strings.","Assert required path configs are non-empty at job startup.","Log the source of each dynamically-built path string for easier debugging."],"tags":["path","validation","configuration","filesystem"],"backgroundTag":null,"analyzedSha":"2f3c205e9266cb30240eb7f4fdab15cad629a70f","analyzedAt":"2026-08-14T08:48:24.518Z","schemaVersion":2},"datasetVersion":"2026-08-14T10:17:34.591Z"}