xpipe-io/xpipe · error · IllegalStateException
Target ${path} is not a directory
Error message
Target ${path} is not a directory What it means
Thrown by BrowserFileTransferOperation.execute when the transfer target BrowserEntry is not a directory. Transfers (move/copy/paste) require a directory target, so the operation aborts with an IllegalStateException before validation proceeds.
Source
Thrown at app/src/main/java/io/xpipe/app/browser/file/BrowserFileTransferOperation.java:167
return false;
}
var same = files.getFirst().getFileSystem().equals(target.getFileSystem());
var doesMove = transferMode == BrowserFileTransferMode.MOVE
|| (same && transferMode == BrowserFileTransferMode.NORMAL);
return doesMove;
}
public void execute() throws Exception {
if (files.isEmpty()) {
updateProgress(null);
return;
}
reinitFileSystemsIfNeeded();
if (target.getKind() != FileKind.DIRECTORY) {
throw new IllegalStateException("Target " + target.getPath() + " is not a directory");
}
BrowserFileSystemHelper.validateDirectoryPath(target.getFileSystem(), target.getPath(), true);
cancelled.set(false);
var same = files.getFirst().getFileSystem().equals(target.getFileSystem());
var doesMove = transferMode == BrowserFileTransferMode.MOVE
|| (same && transferMode == BrowserFileTransferMode.NORMAL);
try {
for (var file : files) {
if (cancelled()) {
break;
}
if (same) {
handleSingleOnSameFileSystem(file);
} else {View on GitHub (pinned to d85ca821ba)
Solutions
- Select a directory as the transfer target
- Refresh the browser and re-select the target to clear stale entries
- In code, check entry.getKind() == FileKind.DIRECTORY before executing the transfer
- If targeting a file's location, resolve its parent directory first
Example fix
// before
transfer(targetFileEntry, files) // kind = FILE
// after
if (target.getKind() == FileKind.DIRECTORY) {
executeTransfer(target, files);
} Defensive patterns
Strategy: validation
Validate before calling
function assertDirectoryTarget(entry) {
if (entry.kind !== 'directory') {
throw new Error(`Target ${entry.path} is not a directory`);
}
}
// call before executing a browser transfer Type guard
function isDirectoryEntry(entry) {
return entry && entry.kind === 'directory';
} Try / catch
try {
op.execute(target, files);
} catch (e) {
if (e instanceof Error && e.message.includes('is not a directory')) {
// re-select a directory target and retry
}
} Prevention
- Refresh the browser before programmatic transfers to avoid stale selections
- Check FileKind before targeting an entry
- Resolve a file target to its parent directory
When it happens
Trigger: Initiating a file paste/move/copy in the XPipe browser while the selected target entry is a file rather than a directory, often after the target was deleted/re-created or a stale selection was used.
Common situations: Stale browser selection after a refresh, programmatically driving transfers with a file path as target, or confusing 'transfer into this file's parent' semantics.
Related errors
- Mixed source file systems
- Source file ${sourceFile} input size mismatch: Expected ${ex
- File path " + msg.getPath() + " is not absolute
- File " + msg.getPath() + " does not exist
- File path " + msg.getPath() + " is not absolute
AI-assisted analysis of xpipe-io/xpipe@d85ca821ba (2026-09-06).
Data as JSON: /api/errors/3dd0a145b2e88d15.
Report an issue: GitHub.