{"record":{"id":"00b116ac560e4d1d","repo":"OtterMind/Chat2DB","slug":"selected-path-is-not-available","errorCode":null,"errorMessage":"Selected path is not available","messagePattern":"Selected path is not available","errorType":"validation","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"warning","filePath":"chat2db-community-server/chat2db-community-jcef/src/main/java/ai/chat2db/community/jcef/handler/biz/SqlDirectoryTreeStore.java","lineNumber":182,"sourceCode":"        result.put(\"children\", listChildren(rootToken, parentRelativePath));\n        return result;\n    }\n\n    static Map<String, Object> renameChild(String rootToken, String relativePath, String rawName)\n            throws IOException {\n        Path root = getRoot(rootToken);\n        Path source = resolveInRoot(root, relativePath);\n        if (source.equals(root)) {\n            throw new IllegalArgumentException(\"Selected SQL directory root cannot be renamed\");\n        }\n        if (Files.isSymbolicLink(source)) {\n            throw new IllegalArgumentException(\"Symbolic links are not supported\");\n        }\n\n        boolean file = Files.isRegularFile(source, LinkOption.NOFOLLOW_LINKS);\n        boolean directory = Files.isDirectory(source, LinkOption.NOFOLLOW_LINKS);\n        if (!file && !directory) {\n            throw new IllegalArgumentException(\"Selected path is not available\");\n        }\n        String sourceFileName = source.getFileName().toString();\n        String fallbackExtension = file ? getFileExtension(sourceFileName) : \"\";\n        String name = file ? normalizeExistingFileName(rawName, fallbackExtension)\n                : normalizeDirectoryName(rawName);\n        Path parent = source.getParent();\n        Path target = parent.resolve(name).normalize();\n        if (!target.startsWith(root)) {\n            throw new IllegalArgumentException(\"Path is outside of the selected SQL directory\");\n        }\n        if (Files.exists(target, LinkOption.NOFOLLOW_LINKS) && !source.equals(target)) {\n            throw new IllegalArgumentException(\"File or directory already exists\");\n        }\n\n        Path movedTarget;\n        try {\n            movedTarget = Files.move(source, target, StandardCopyOption.ATOMIC_MOVE);\n        } catch (IOException exception) {","sourceCodeStart":164,"sourceCodeEnd":200,"githubUrl":"https://github.com/OtterMind/Chat2DB/blob/5ee1e990e73fbcae1969dc554be254fedb3ab888/chat2db-community-server/chat2db-community-jcef/src/main/java/ai/chat2db/community/jcef/handler/biz/SqlDirectoryTreeStore.java#L164-L200","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","solutions":["Refresh the tree to verify the source still exists as a regular file or directory","Handle the error and inform the user that the selected item is no longer available","Check for concurrent operations on the same directory subtree"],"exampleFix":null,"handlingStrategy":"validation","validationCode":"// Before calling renameChild, verify the source is a regular file or directory\nif (!Files.isRegularFile(source, LinkOption.NOFOLLOW_LINKS)\n        && !Files.isDirectory(source, LinkOption.NOFOLLOW_LINKS)) {\n    throw new IllegalArgumentException(\"Source is not a valid file or directory\");\n}\nSqlDirectoryTreeStore.renameChild(rootToken, relativePath, rawName);","typeGuard":null,"tryCatchPattern":"try {\n    Map<String, Object> result = SqlDirectoryTreeStore.renameChild(rootToken, relativePath, name);\n    ResponseBuilder.buildSuccessJcef(Map.of(\"data\", result), callback);\n} catch (IllegalArgumentException e) {\n    callback.failure(400, e.getMessage());\n}","preventionTips":["Refresh the tree before allowing rename operations on nodes loaded long ago","Handle stale-node errors by refreshing the tree and re-selecting the node","Check for concurrent operations (terminal sessions, external editors) that may delete files"],"tags":["sql-directory","rename","path-validation","filesystem","stale-state"],"backgroundTag":null,"analyzedSha":"5ee1e990e73fbcae1969dc554be254fedb3ab888","analyzedAt":"2026-08-14T07:05:03.077Z","schemaVersion":2},"datasetVersion":"2026-08-14T10:17:34.591Z"}