twentyhq/twenty · critical · Error

Failed to backfill standard skills for workspace

Error message

Failed to backfill standard skills for workspace ${workspaceId}

What it means

Thrown by the 2.27 command that backfills standard Skills into existing workspaces. It builds skill flat entities and submits them via validateBuildAndRunLegacyWorkspaceMigration; on status === 'fail' it logs the full report then throws. The failure is in the skill flat-entity operations — the orchestrator's report (nested under the logged JSON) identifies which skill(s) and which validation rule failed.

Solutions

  1. Inspect the logged JSON report (this command logs it via logger.error before throwing) — find the failing skill universalIdentifier and the error code.
  2. Verify the referenced application and any object/field identifiers the skill depends on exist for the workspace (query core.metadata).
  3. Remove or repair colliding/dangling skill rows for that workspace, then re-run the 2.27 command.
  4. If upgrading across many skipped versions, run the intermediate major upgrades first so all dependent metadata exists.
Defensive patterns

Strategy: try-catch

Try / catch

try {
  await command.runOnWorkspace({ workspaceId, options });
} catch (e) {
  // the command logs the full report via logger.error before throwing;
  // capture workspaceId and continue the per-workspace loop.
  upgradeRunner.markWorkspaceFailed(workspaceId, e);
}

Prevention

When it happens

Trigger: A skill flat entity references an application/object/field universalIdentifier that does not exist in the target workspace; a skill universalIdentifier already exists with a different shape (collision); a dependent relation or workflow node references a skill that the validator cannot resolve; the twentyStandardFlatApplication record is missing or mislinked for the workspace.

Common situations: Workspace created on an older release where the standard application seed diverged from current code; partial earlier skill seeding that left half-written rows; cross-version upgrade skipping intermediate releases so dependent metadata (objects the skills reference) is absent.

Related errors


AI-assisted analysis of twentyhq/twenty@1f5dd2bbd2 (2026-08-12). Data as JSON: /api/errors/13b8ce6d1d72db32. Report an issue: GitHub.

Appendix: source

Thrown at packages/twenty-server/src/database/commands/upgrade-version-command/2-27/2-27-workspace-command-1785499350000-backfill-standard-skills.command.ts:110

          allFlatEntityOperationByMetadataName: {
            skill: {
              flatEntityToCreate: skillsToCreate,
              flatEntityToDelete: [],
              flatEntityToUpdate: [],
            },
          },
          workspaceId,
          applicationUniversalIdentifier:
            twentyStandardFlatApplication.universalIdentifier,
        },
      );

    if (validateAndBuildResult.status === 'fail') {
      this.logger.error(
        `Failed to backfill standard skills:\n${JSON.stringify(validateAndBuildResult, null, 2)}`,
      );

      throw new Error(
        `Failed to backfill standard skills for workspace ${workspaceId}`,
      );
    }

    this.logger.log(
      `Successfully created ${skillsToCreate.length} standard skill(s) for workspace ${workspaceId}`,
    );
  }
}

View on GitHub (pinned to 1f5dd2bbd2)