twentyhq/twenty · error · Error

Failed to create CalendarEvent record page metadata for work

Error message

Failed to create CalendarEvent record page metadata for workspace ${workspaceId}: ${JSON.stringify(validateAndBuildResult, null, 2)}

What it means

Thrown by the 2.15 command that syncs the CalendarEvent record page (page + pageTab + pageLayout + pageLayoutWidget) when validateBuildAndRunLegacyWorkspaceMigration returns status 'fail'. The full validateAndBuildResult is JSON-stringified into the message. It signals the build rejected the page-metadata creation payload for the workspace.

Source

Thrown at packages/twenty-server/src/database/commands/upgrade-version-command/2-15/2-15-workspace-command-1800000002000-sync-calendar-event-record-page.command.ts:283

              flatEntityToDelete: [],
              flatEntityToUpdate: [],
            },
            pageLayoutTab: {
              flatEntityToCreate: pageLayoutTabsToCreate,
              flatEntityToDelete: [],
              flatEntityToUpdate: [],
            },
            pageLayoutWidget: {
              flatEntityToCreate: pageLayoutWidgetsToCreate,
              flatEntityToDelete: [],
              flatEntityToUpdate: [],
            },
          },
        },
      );

    if (validateAndBuildResult.status === 'fail') {
      throw new Error(
        `Failed to create CalendarEvent record page metadata for workspace ${workspaceId}: ${JSON.stringify(
          validateAndBuildResult,
          null,
          2,
        )}`,
      );
    }

    this.logger.log(
      `Created ${totalOperationCount} CalendarEvent record page metadata item(s) for workspace ${workspaceId}`,
    );
  }
}

View on GitHub (pinned to 1f5dd2bbd2)

Solutions

  1. Inspect the JSON payload in the message to find the failing entity and error codes.
  2. Confirm CalendarEvent standard object and fields are present and match the image's seed before this command.
  3. Resolve conflicting page/pageTab rows (delete the half-created ones from a prior failed run) and re-run.
  4. Rebuild and redeploy the server image if the page-layout seed is stale.
Defensive patterns

Strategy: validation

Validate before calling

// Confirm CalendarEvent object and its base fields match the standard seed
// before the record-page command runs.
const ev = await dataSource.query(`SELECT id FROM core."objectMetadata" WHERE "nameSingular" = 'calendarEvent' AND "isActive" = true`);
if (!ev.length) throw new Error('CalendarEvent object missing; run prerequisite migrations first');

Type guard

function isFailResult(r: unknown): r is { status: 'fail' } {
  return typeof r === 'object' && r !== null && (r as any).status === 'fail';
}

Try / catch

try {
  const res = await service.validateBuildAndRunLegacyWorkspaceMigration(payload);
  if (res.status === 'fail') throw new Error(`...${JSON.stringify(res, null, 2)}`);
} catch (err) { upgradeAudit.record(workspaceId, command.id, err); throw err; }

Prevention

When it happens

Trigger: Running the 2.15 upgrade on a workspace whose CalendarEvent object or base fields do not match the standard seed (so the page layout cannot resolve fieldMetadataId references), or where a page/pageTab with the same universal identifier already exists in a state the validator treats as a conflict.

Common situations: Standard seed drift between image and workspace; partial prior migration that created the pageTab but not the page; custom CalendarEvent page edits conflicting with the standard definition.

Related errors


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