xpipe-io/xpipe · error · IllegalArgumentException

Name must not be empty

Error message

Name must not be empty

What it means

StorePath.fromString splits the input on the SEPARATOR character and trims/lowercases each segment. If any resulting segment is empty (e.g. leading/trailing separators or consecutive separators like "a//b" or "/a"), the parser throws this IllegalArgumentException because empty path names are not allowed.

Source

Thrown at app/src/main/java/io/xpipe/app/util/StorePath.java:74

    }

    /**
     * Creates a new store path from a string representation.
     *
     * @param s the string representation, must be not null and fulfill certain requirements
     * @throws IllegalArgumentException if the string is not valid
     */
    public static StorePath fromString(String s) {
        if (s == null) {
            throw new IllegalArgumentException("String is null");
        }

        var split = s.split(String.valueOf(SEPARATOR), -1);

        var names =
                Arrays.stream(split).map(String::trim).map(String::toLowerCase).toList();
        if (names.stream().anyMatch(s1 -> s1.isEmpty())) {
            throw new IllegalArgumentException("Name must not be empty");
        }

        return new StorePath(names);
    }

    @Override
    public String toString() {
        return names.stream().map(String::toLowerCase).collect(Collectors.joining("" + SEPARATOR));
    }
}

View on GitHub (pinned to d85ca821ba)

Solutions

  1. Strip leading/trailing separators before parsing: s.replaceAll("^" + SEPARATOR + "|" + SEPARATOR + "$", "").
  2. Pre-validate the string: Arrays.stream(s.split(SEPARATOR + "")).noneMatch(String::isBlank).
  3. Fix whatever builds the string so empty segments are never emitted (e.g. String.join).

Example fix

// before
StorePath p = StorePath.fromString(raw);
// after
String cleaned = raw.strip();
while (cleaned.startsWith(String.valueOf(StorePath.SEPARATOR))) cleaned = cleaned.substring(1);
while (cleaned.endsWith(String.valueOf(StorePath.SEPARATOR))) cleaned = cleaned.substring(0, cleaned.length() - 1);
StorePath p = StorePath.fromString(cleaned);
Defensive patterns

Strategy: validation

Validate before calling

public static boolean isWellFormedPath(String s) {
    if (s == null) return false;
    String[] parts = s.split(String.valueOf(StorePath.SEPARATOR));
    return parts.length > 0 && Arrays.stream(parts).noneMatch(String::isBlank);
}

Try / catch

try {
    StorePath p = StorePath.fromString(s);
} catch (IllegalArgumentException e) {
    // empty segment: leading/trailing/duplicate separator
}

Prevention

When it happens

Trigger: StorePath.fromString("") (empty split yields one empty name), fromString("a//b"), fromString("/leading"), fromString("trailing/"), or any segment that is only whitespace around separators.

Common situations: Hand-edited config files with stray separators; string concatenation that appends SEPARATOR unconditionally; copying a path with a trailing slash into the store path field.

Understand the failure class

Background: "invalid id" errors: invalid identifier format — why libraries reject IDs before lookup, and how to fix them — this error's family across 37 libraries.

Related errors


AI-assisted analysis of xpipe-io/xpipe@d85ca821ba (2026-09-06). Data as JSON: /api/errors/7edfe8448e456290. Report an issue: GitHub.