infiniflow/ragflow · error · Error

Failed to get skill folder ID

Error message

Failed to get skill folder ID

What it means

Thrown in web/src/pages/skills/hooks.ts:827 when the skill folder id is still falsy after both branches (reuse-existing and create-new) ran. It is a consistency guard: either the created folder response omitted data.id, or an assignment path silently produced undefined (e.g. existingSkill found but with no id, or a branch was skipped).

Source

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

          } else {
            // Create skill folder
            const folderRes = await fileManagerService.createFolder({
              name: skillNameNormalized,
              type: 'folder',
              parent_id: spaceFolderId,
            });

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

            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

View on GitHub (pinned to 554fb1133a)

Solutions

  1. Log the raw createFolder/listFile responses to see which id field is missing
  2. Guard each branch: throw immediately if existingSkill.id or folderRes.data.data?.id is falsy, with branch-specific messages
  3. Align the response typing (data.data.id) with the current backend contract
  4. Retry folder creation once if the response was code 0 but id-less

Example fix

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

// after
if (!skillFolderId) {
  throw new Error(
    'Failed to get skill folder ID (created=' +
      String(createdFolder) +
      ', reused=' +
      String(reusedFolder) +
      ')',
  );
}
Defensive patterns

Strategy: validation

Validate before calling

const folderIdFrom = (res: any): string | null =>
  res?.data?.data?.id ?? res?.data?.id ?? null;

Type guard

const isNonEmptyId = (v: unknown): v is string =>
  typeof v === 'string' && v.trim().length > 0;

Prevention

When it happens

Trigger: createFolder returns code 0 but data.id is missing (backend response shape change); existing skill folder matched with an undefined id field; a code path assigns skillFolderId from a nested optional that is absent.

Common situations: Backend API response schema drift after an upgrade. Partial/trimmed backend response under proxy buffering. Tests stubbing createFolder without an id.

Related errors


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