xpipe-io/xpipe · error · ValidationException

Directory is a root

Error message

Directory is a root

What it means

The directory icon source's checkComplete() validates that the chosen path has a parent. Passing a filesystem root (e.g. '/' or 'C:\') yields path.getParent() == null, and a ValidationException is thrown because a root directory cannot serve as an icon source target.

Source

Thrown at app/src/main/java/io/xpipe/app/icon/SystemIconSource.java:56

    String getDescription();

    void open();

    @Value
    @Builder
    @Jacksonized
    @JsonTypeName("directory")
    class Directory implements SystemIconSource {

        Path path;
        String id;

        @Override
        public void checkComplete() throws ValidationException {
            Validators.nonNull(path);
            if (path.getParent() == null) {
                throw new ValidationException("Directory is a root");
            }
            Validators.notEmpty(id);
        }

        @Override
        public void refresh() {}

        @Override
        public Path getPath() {
            return path;
        }

        @Override
        public String getIcon() {
            return "mdi2f-folder";
        }

        @Override

View on GitHub (pinned to d85ca821ba)

Solutions

  1. Select a non-root subdirectory as the icon source path
  2. Use Path.of(".").toRealPath() and then descend into a subdirectory instead of an empty/root path
  3. Add a UI-side guard rejecting root paths before completing the form

Example fix

// before
var path = Path.of("");
source.path(path);
// after
var path = Path.of(".").toRealPath().resolve("assets");
source.path(path);
Defensive patterns

Strategy: validation

Validate before calling

if (path == null || path.getParent() == null) throw new ValidationException("Directory is a root");
if (path.toString().isBlank()) throw new ValidationException("Path is empty");

Type guard

boolean isNonRootDir(Path p) { return p != null && p.getParent() != null && Files.isDirectory(p); }

Try / catch

try { source.checkComplete(); } catch (ValidationException e) { /* show picker again, disallow root selection */ }

Prevention

When it happens

Trigger: Calling checkComplete() on a DirectoryIconSource builder/state where path was set to a filesystem root via Paths.get("") or a drive root.

Common situations: User selects '/' or a drive letter in the icon-source picker; code passing Path.of("") (empty path resolves to the current root-relative path with no parent) instead of a real subdirectory.

Understand the failure class

Background: "Must be a positive integer", "Invalid value", "Unsupported": the invalid-argument-value error family, when a library rejects the value you pass — this error's family across 35 libraries.

Related errors


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