OtterMind/Chat2DB · warning · IllegalArgumentException
Unsupported SQL directory child type
Error message
Unsupported SQL directory child type
What it means
Thrown by SqlDirectoryTreeStore.createChild() when the 'type' parameter is neither 'directory' nor 'file'. The method checks exact string equality against these two values and rejects anything else. This is a contract violation between the frontend and the JCEF bridge — the type enum is not extensible.
Source
Thrown at chat2db-community-server/chat2db-community-jcef/src/main/java/ai/chat2db/community/jcef/handler/biz/SqlDirectoryTreeStore.java:119
overflowNode.put("loaded", true);
children.add(overflowNode);
}
return children;
}
static Map<String, Object> createChild(String rootToken, String parentRelativePath, String rawName, String type)
throws IOException {
Path root = getRoot(rootToken);
Path parent = resolveInRoot(root, parentRelativePath);
if (!Files.isDirectory(parent, LinkOption.NOFOLLOW_LINKS)) {
throw new IllegalArgumentException("Selected path is not a directory");
}
boolean directory = "directory".equals(type);
boolean file = "file".equals(type);
if (!directory && !file) {
throw new IllegalArgumentException("Unsupported SQL directory child type");
}
String name = file ? normalizeFileName(rawName, "sql") : normalizeDirectoryName(rawName);
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)) {
throw new IllegalArgumentException("File or directory already exists");
}
if (directory) {
Files.createDirectory(target);
} else {
Files.createFile(target);
}
Path realTarget = target.toRealPath(LinkOption.NOFOLLOW_LINKS);View on GitHub (pinned to 5ee1e990e7)
Solutions
- Ensure the frontend sends exactly 'directory' or 'file' as the type value
- Add frontend validation that maps UI labels to the exact backend enum before sending the request
- Document the accepted type values in the API contract shared between frontend and backend
Example fix
// before: frontend sends arbitrary type label
createChild(rootToken, parentPath, name, uiLabel); // uiLabel = 'folder'
// after: normalize to backend contract
const typeMap = { folder: 'directory', dir: 'directory', file: 'file' };
createChild(rootToken, parentPath, name, typeMap[uiLabel] ?? uiLabel); Defensive patterns
Strategy: type-guard
Validate before calling
// Validate type before calling createChild
private static final Set<String> VALID_TYPES = Set.of("directory", "file");
if (!VALID_TYPES.contains(type)) {
throw new IllegalArgumentException("Type must be 'directory' or 'file', got: " + type);
}
SqlDirectoryTreeStore.createChild(rootToken, parentRelativePath, name, type); Type guard
// Type guard for the child type enum
static boolean isValidChildType(String type) {
return "directory".equals(type) || "file".equals(type);
} Try / catch
try {
Map<String, Object> result = SqlDirectoryTreeStore.createChild(rootToken, parentRelativePath, name, type);
ResponseBuilder.buildSuccessJcef(Map.of("data", result), callback);
} catch (IllegalArgumentException e) {
callback.failure(400, e.getMessage());
} Prevention
- Map frontend UI labels to the exact backend enum ('directory', 'file') before sending
- Share the type enum as a TypeScript union type in the frontend contract
- Default the type to 'file' if the frontend does not explicitly set it
When it happens
Trigger: Invoked via create-sql-directory-child JCEF action when the JSON 'type' field is null, empty, or an unrecognized string (e.g., 'folder', 'dir', 'document', 'symlink').
Common situations: Frontend uses a different label for the type (e.g., 'folder' instead of 'directory'); the type field is omitted from the request; a new file type was added to the frontend without updating the backend contract.
Related errors
- Selected path is not a directory
- File or directory already exists
- Selected SQL directory root cannot be renamed
- Selected SQL directory root cannot be deleted
- License flow is disabled in community mode
AI-assisted analysis of OtterMind/Chat2DB@5ee1e990e7 (2026-08-14).
Data as JSON: /api/errors/255624b165ee5c6f.
Report an issue: GitHub.