{"record":{"id":"c3d4f696690541a7","repo":"MuntashirAkon/AppManager","slug":"display-name-is-empty","errorCode":null,"errorMessage":"Display name is empty","messagePattern":"Display name is empty","errorType":"validation","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"app/src/main/java/io/github/muntashirakon/io/PathImpl.java","lineNumber":436,"sourceCode":"        }\n        for (String name : dirNames) {\n            if (name.equals(\"..\")) {\n                throw new IOException(\"Could not create directories in the parent directory.\");\n            }\n        }\n        DocumentFile file = createArbitraryDirectories(documentFile, dirNames, dirNames.length);\n        return new PathImpl(context, file);\n    }\n\n    @NonNull\n    public Path createDirectories(@NonNull String displayName) throws IOException {\n        displayName = Paths.sanitize(displayName, true);\n        if (displayName == null) {\n            throw new IOException(\"Empty display name.\");\n        }\n        String[] dirNames = displayName.split(File.separator);\n        if (dirNames.length == 0) {\n            throw new IllegalArgumentException(\"Display name is empty\");\n        }\n        for (String name : dirNames) {\n            if (name.equals(\"..\")) {\n                throw new IOException(\"Could not create directories in the parent directory.\");\n            }\n        }\n        DocumentFile file = createArbitraryDirectories(documentFile, dirNames, dirNames.length - 1);\n        // Special case for the last segment\n        String lastSegment = dirNames[dirNames.length - 1];\n        Path fsRoot = VirtualFileSystem.getFsRoot(Paths.appendPathSegment(file.getUri(), lastSegment));\n        DocumentFile t = fsRoot != null ? fsRoot.documentFile : file.findFile(lastSegment);\n        if (t != null) {\n            throw new IOException(t.getUri() + \" already exists.\");\n        }\n        t = file.createDirectory(lastSegment);\n        if (t == null) {\n            throw new IOException(\"Directory\" + file.getUri() + File.separator + lastSegment + \" could not be created.\");\n        }","sourceCodeStart":418,"sourceCodeEnd":454,"githubUrl":"https://github.com/MuntashirAkon/AppManager/blob/0152f468fc9463ee02dc2ca83f6fe4989a2c4ca5/app/src/main/java/io/github/muntashirakon/io/PathImpl.java#L418-L454","documentation":"PathImpl.createDirectories() splits the sanitized display name on the file separator; when splitting yields an empty segment array (e.g. the name was only separators like \"/\"), it throws IllegalArgumentException(\"Display name is empty\"). The library requires at least one concrete directory segment to create. It is a programmer error, not an environment failure.","triggerScenarios":"Calling createDirectories with a name that sanitizes to only path separators, e.g. \"/\" or \"//\", so displayName.split(File.separator) produces zero usable segments.","commonSituations":"Building the directory name by joining path components with a separator and passing the result including a trailing/leading slash; concatenating an empty variable into a path string; passing a URI path portion instead of a display name.","solutions":["Pass a concrete relative directory name without leading/trailing slashes, e.g. \"foo/bar\" instead of \"/foo/bar/\".","Strip leading/trailing File.separator from the input before calling createDirectories.","Validate that the trimmed name is non-empty and contains at least one non-separator character before calling.","Split the path yourself and call createDirectories per-level if you need root-relative handling."],"exampleFix":"// before\npath.createDirectories(\"/mydir/\"); // IllegalArgumentException: Display name is empty\n// after\nString name = \"/mydir/\".replaceAll(\"^/+|/+$\", \"\");\nif (!name.isEmpty()) path.createDirectories(name);","handlingStrategy":"validation","validationCode":"String name = raw == null ? \"\" : raw.replaceAll(\"^\"+File.separator+\"+|\"+File.separator+\"+$\", \"\");\nif (name.isEmpty() || name.split(File.separator).length == 0) throw new IllegalArgumentException(\"Need at least one directory segment\");","typeGuard":"boolean isCreatableDirName(String n) { return n != null && !n.replaceAll(\"^/+|/+$\", \"\").isEmpty(); }","tryCatchPattern":"try { path.createDirectories(name); } catch (IllegalArgumentException e) { log.warn(\"Rejecting empty dir name\", e); }","preventionTips":["Never pass absolute or slash-delimited-with-empty-segments names","Trim separators before calling","Build names with Paths.appendPathSegment instead of string concat"],"tags":["android","filesystem","illegal-argument","path"],"backgroundTag":"empty-required-field","analyzedSha":"0152f468fc9463ee02dc2ca83f6fe4989a2c4ca5","analyzedAt":"2026-09-12T14:03:37.243Z","contentChangedAt":"2026-09-12T14:03:37.243Z","schemaVersion":2},"datasetVersion":"2026-09-14T11:17:12.474Z"}