OtterMind/Chat2DB · warning · IllegalArgumentException

Selected path is not available

Error message

Selected path is not available

What it means

Thrown by SqlDirectoryTreeStore.renameChild() when the source is neither a regular file nor a directory (both checked with NOFOLLOW_LINKS). This catches paths that were deleted between tree listing and rename, or special file types (pipes, sockets, device files) that cannot be renamed through this API.

Source

Thrown at chat2db-community-server/chat2db-community-jcef/src/main/java/ai/chat2db/community/jcef/handler/biz/SqlDirectoryTreeStore.java:182

        result.put("children", listChildren(rootToken, parentRelativePath));
        return result;
    }

    static Map<String, Object> renameChild(String rootToken, String relativePath, String rawName)
            throws IOException {
        Path root = getRoot(rootToken);
        Path source = resolveInRoot(root, relativePath);
        if (source.equals(root)) {
            throw new IllegalArgumentException("Selected SQL directory root cannot be renamed");
        }
        if (Files.isSymbolicLink(source)) {
            throw new IllegalArgumentException("Symbolic links are not supported");
        }

        boolean file = Files.isRegularFile(source, LinkOption.NOFOLLOW_LINKS);
        boolean directory = Files.isDirectory(source, LinkOption.NOFOLLOW_LINKS);
        if (!file && !directory) {
            throw new IllegalArgumentException("Selected path is not available");
        }
        String sourceFileName = source.getFileName().toString();
        String fallbackExtension = file ? getFileExtension(sourceFileName) : "";
        String name = file ? normalizeExistingFileName(rawName, fallbackExtension)
                : normalizeDirectoryName(rawName);
        Path parent = source.getParent();
        Path target = parent.resolve(name).normalize();
        if (!target.startsWith(root)) {
            throw new IllegalArgumentException("Path is outside of the selected SQL directory");
        }
        if (Files.exists(target, LinkOption.NOFOLLOW_LINKS) && !source.equals(target)) {
            throw new IllegalArgumentException("File or directory already exists");
        }

        Path movedTarget;
        try {
            movedTarget = Files.move(source, target, StandardCopyOption.ATOMIC_MOVE);
        } catch (IOException exception) {

View on GitHub (pinned to 5ee1e990e7)

Solutions

  1. Refresh the tree to verify the source still exists as a regular file or directory
  2. Handle the error and inform the user that the selected item is no longer available
  3. Check for concurrent operations on the same directory subtree
Defensive patterns

Strategy: validation

Validate before calling

// Before calling renameChild, verify the source is a regular file or directory
if (!Files.isRegularFile(source, LinkOption.NOFOLLOW_LINKS)
        && !Files.isDirectory(source, LinkOption.NOFOLLOW_LINKS)) {
    throw new IllegalArgumentException("Source is not a valid file or directory");
}
SqlDirectoryTreeStore.renameChild(rootToken, relativePath, rawName);

Try / catch

try {
    Map<String, Object> result = SqlDirectoryTreeStore.renameChild(rootToken, relativePath, name);
    ResponseBuilder.buildSuccessJcef(Map.of("data", result), callback);
} catch (IllegalArgumentException e) {
    callback.failure(400, e.getMessage());
}

Prevention

When it happens

Trigger: The source path exists (it passed resolveInRoot without throwing NoSuchFileException because toRealPath succeeded) but is not a regular file or directory. The file was deleted and recreated as a special file, or the source was deleted by a concurrent operation and the filesystem reports it as neither file nor directory during the check window.

Common situations: Source file deleted by another process between tree load and rename; source is a Unix special file (pipe, socket, device node); a race condition where the file is being replaced.

Related errors


AI-assisted analysis of OtterMind/Chat2DB@5ee1e990e7 (2026-08-14). Data as JSON: /api/errors/00b116ac560e4d1d. Report an issue: GitHub.