infiniflow/ragflow · error · Error

Failed to create version folder

Error message

Failed to create version folder

What it means

Thrown in web/src/pages/skills/hooks.ts:837 when createFolder for the skill's version subfolder (e.g. '1.0.0' under the skill folder) returns code !== 0. Uploads are organized as space/skill/version/, so the version folder must exist before files land. Typical causes: the version folder already exists (re-upload of the same version) or the skill folder id became invalid.

Source

Thrown at web/src/pages/skills/hooks.ts:837

            }

            skillFolderId = folderRes.data.data?.id;
          }
        } else {
          throw new Error('Failed to list skills folder');
        }

        if (!skillFolderId) throw new Error('Failed to get skill folder ID');

        // Create version folder
        const versionRes = await fileManagerService.createFolder({
          name: version,
          type: 'folder',
          parent_id: skillFolderId,
        });

        if (versionRes.data.code !== 0) {
          throw new Error('Failed to create version folder');
        }

        const versionFolderId = versionRes.data.data?.id;

        if (!versionFolderId)
          throw new Error('Failed to get version folder ID');

        // Upload files recursively to preserve directory structure
        const uploadFileWithStructure = async (
          file: File,
          parentId: string,
        ) => {
          const relativePath = (file as any).webkitRelativePath || file.name;
          const pathParts = relativePath.split('/');

          // If file is in root directory (no subdirectories)
          if (pathParts.length === 1) {
            const formData = new FormData();

View on GitHub (pinned to 554fb1133a)

Solutions

  1. Before creating, list skillFolderId and reuse an existing folder whose name matches the version
  2. Require a non-empty semver-like version in the form and disable upload otherwise
  3. Surface createFolder's response message in the error
  4. Bump the version number when re-uploading a modified skill

Example fix

// before
const versionRes = await fileManagerService.createFolder({
  name: version,
  type: 'folder',
  parent_id: skillFolderId,
});
if (versionRes.data.code !== 0) {
  throw new Error('Failed to create version folder');
}

// after
const { data: skillContents } = await fileManagerService.listFile({
  parent_id: skillFolderId,
});
const existingVersion = (skillContents.data?.files || []).find(
  (f: any) => f.type === 'folder' && f.name === version,
);
const versionFolderId =
  existingVersion?.id ??
  (
    await fileManagerService.createFolder({
      name: version,
      type: 'folder',
      parent_id: skillFolderId,
    })
  ).data.data?.id;
if (!versionFolderId) {
  throw new Error('Failed to create version folder');
}
Defensive patterns

Strategy: validation

Validate before calling

const isValidVersion = (v: string) => /^\d+\.\d+\.\d+/.test(v.trim());
const versionFolderExists = async (skillFolderId: string, version: string) =>
  (await fileManagerService.listFile({ parent_id: skillFolderId }))
    .data.data?.files?.some((f) => f.type === 'folder' && f.name === version) ?? false;

Type guard

const isSemver = (v: unknown): v is string =>
  typeof v === 'string' && /^\d+\.\d+\.\d+/.test(v);

Prevention

When it happens

Trigger: Re-uploading the same skill at the same version: the version folder already exists and the backend rejects the duplicate; skillFolderId stale after a concurrent delete; invalid version string (empty or with characters the backend rejects) used as folder name.

Common situations: Uploading an updated skill without bumping the version. Version input left blank, producing an odd folder name. Two uploads racing on the same skill+version.

Related errors


AI-assisted analysis of infiniflow/ragflow@554fb1133a (2026-08-15). Data as JSON: /api/errors/56a4e9d4f2c34cc3. Report an issue: GitHub.