infiniflow/ragflow · error · Error
Failed to list directory: ${dirName}
Error message
Failed to list directory: ${dirName} What it means
Thrown in web/src/pages/skills/hooks.ts:873 during recursive upload: while walking the file's webkitRelativePath directory chain, a fileManagerService.listFile on the current parent returns code !== 0. The walker needs to know whether each subdirectory already exists before creating it; if the listing fails, the traversal aborts with the failing directory name embedded in the message.
Source
Thrown at web/src/pages/skills/hooks.ts:873
const formData = new FormData();
formData.append('parent_id', parentId);
formData.append('file', file);
await fileManagerService.uploadFile(formData);
return;
}
// Navigate/create directory structure
let currentParentId = parentId;
for (let i = 0; i < pathParts.length - 1; i++) {
const dirName = pathParts[i];
// List current directory to check if subdirectory exists
const { data: listData } = await fileManagerService.listFile({
parent_id: currentParentId,
});
if (listData.code !== 0) {
throw new Error(`Failed to list directory: ${dirName}`);
}
const existingDir = listData.data?.files?.find(
(f: any) => f.name === dirName && f.type === 'folder',
);
if (existingDir) {
currentParentId = existingDir.id;
} else {
// Create subdirectory
const createRes = await fileManagerService.createFolder({
name: dirName,
type: 'folder',
parent_id: currentParentId,
});
if (createRes.data.code !== 0) {
throw new Error(`Failed to create directory: ${dirName}`);View on GitHub (pinned to 554fb1133a)
Solutions
- Include the response code/message alongside dirName in the error
- Retry the listFile once after a short delay before failing (transient errors)
- Re-authenticate and restart the upload for very large trees
- Check the file manager UI to confirm the parent chain still exists before retrying
Example fix
// before
if (listData.code !== 0) {
throw new Error(`Failed to list directory: ${dirName}`);
}
// after
if (listData.code !== 0) {
throw new Error(
`Failed to list directory ${dirName} (code ${listData.code}): ${
listData.message || 'unknown error'
}`,
);
} Defensive patterns
Strategy: retry
Validate before calling
const canList = async (parentId: string) =>
parentId != null &&
(await fileManagerService.listFile({ parent_id: parentId })).data.code === 0; Try / catch
try {
const { data } = await fileManagerService.listFile({ parent_id });
if (data.code !== 0) throw new Error(data.message);
} catch (e) {
await backoffRetry(); // transient under load
} Prevention
- Batch the whole folder tree creation up front, then upload files, to shorten the traversal window
- Refresh auth before large multi-level uploads
When it happens
Trigger: Uploading a skill with nested folders (src/, docs/…) where a mid-traversal listFile fails because the parent folder was deleted concurrently; token expiry during a long multi-file upload; backend file-manager transient error; currentParentId undefined after a previous step silently failed.
Common situations: Large skill packages with deep folder trees outlasting the auth session. Another user reorganizing the same space mid-upload. Flaky backend under load.
Related errors
- Skills space not found
- Failed to create skill folder
- Failed to list skills folder
- Failed to get skill folder ID
- Failed to create version folder
AI-assisted analysis of infiniflow/ragflow@554fb1133a (2026-08-15).
Data as JSON: /api/errors/f03d2924c9e4a7c0.
Report an issue: GitHub.