MuntashirAkon/AppManager · error · IOException

Empty display name.

Error message

Empty display name.

What it means

PathImpl.createNewFile(displayName, mimeType) first sanitizes the requested display name; Paths.sanitize with emptyOk=true returns null when the name is empty or reduces to nothing after removing invalid segments. The library throws this IOException to reject creating a file with no usable name.

Solutions

  1. Validate the display name is non-empty and contains only valid filename characters before calling createNewFile
  2. If the name comes from user input, show a validation error instead of calling the API
  3. If the name may contain path segments, use createNewArbitraryFile or createDirectoriesIfRequired instead

Example fix

// before
path.createNewFile(name, "text/plain"); // name may be ""
// after
if (name == null || name.trim().isEmpty()) throw new IllegalArgumentException("File name required");
path.createNewFile(name.trim(), "text/plain");
Defensive patterns

Strategy: validation

Validate before calling

if (displayName == null || displayName.trim().isEmpty() || displayName.matches(".*[\\/:*?\"<>|].*")) { rejectInput(); }

Prevention

When it happens

Trigger: Calling createNewFile with an empty string, a string of only separators/invalid characters (e.g. "/", "..", trailing dots on some providers), or a name that sanitize strips entirely.

Common situations: Building the name from user input without validation; splitting a path and passing an empty trailing segment; trimming logic that removes all characters before the call.

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 MuntashirAkon/AppManager@0152f468fc (2026-09-12). Data as JSON: /api/errors/941458159569ae2a. Report an issue: GitHub.

Appendix: source

Thrown at app/src/main/java/io/github/muntashirakon/io/PathImpl.java:366

                return f.createNewFile();
            } catch (IOException | SecurityException e) {
                return false;
            }
        }
        // In other cases, open OutputStream to make the file empty.
        // We can directly use openOutputStream because if it were a mount point, it would be a directory.
        try (OutputStream ignored = openOutputStream(false)) {
            return true;
        } catch (IOException e) {
            return false;
        }
    }

    @NonNull
    public Path createNewFile(@NonNull String displayName, @Nullable String mimeType) throws IOException {
        displayName = Paths.sanitize(displayName, true);
        if (displayName == null) {
            throw new IOException("Empty display name.");
        }
        return createFileAsDirectChild(context, documentFile, displayName, mimeType);
    }

    @NonNull
    public Path createNewDirectory(@NonNull String displayName) throws IOException {
        displayName = Paths.sanitize(displayName, true);
        if (displayName == null) {
            throw new IOException("Empty display name.");
        }
        if (displayName.indexOf(File.separatorChar) != -1) {
            throw new IllegalArgumentException("Display name contains file separator.");
        }
        DocumentFile documentFile = getRealDocumentFile(this.documentFile);
        if (!documentFile.isDirectory()) {
            throw new IOException("Current file is not a directory.");
        }
        checkVfs(Paths.appendPathSegment(documentFile.getUri(), displayName));

View on GitHub (pinned to 0152f468fc)