twentyhq/twenty · error · Error

Failed to create messageList view for workspace

Error message

Failed to create messageList view for workspace ${workspaceId}

What it means

Thrown by the 2.20 create-message-list-view command when result.status === 'fail' after attempting to create the messageList view and its view fields for the workspace. The logger.error above prints the full result. Standard seed checks (138) have passed, so this is a per-workspace build-phase rejection.

Solutions

  1. Read the logger.error JSON to find the failing entity and error code.
  2. Inspect the view and viewField metadata tables for existing messageList rows that conflict; remove or reconcile.
  3. Confirm the Message object exists and matches the standard seed.
  4. Re-run the workspace upgrade.
Defensive patterns

Strategy: validation

Validate before calling

// Confirm no conflicting messageList view/rows already exist.
const existing = await dataSource.query(`
  SELECT id FROM core."view" WHERE "nameSingular" = 'messageList' OR "universalIdentifier" = $1
`, [LIST_VIEW_UNIVERSAL_IDENTIFIER]);
if (existing.length) throw new Error('messageList view already exists; reconcile before upgrade');

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(`... for workspace ${workspaceId}`);
} catch (err) { upgradeAudit.record(workspaceId, command.id, err); throw err; }

Prevention

When it happens

Trigger: Running the 2.20 upgrade on a workspace where a messageList view or its view fields already exist in a conflicting state, where the Message object is missing/inconsistent, or where the create payload fails schema validation.

Common situations: Workspace with a pre-existing messageList view that conflicts; prior partial run leaving half-created rows; Message object drifted from standard; concurrent migrations.

Related errors


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

Appendix: source

Thrown at packages/twenty-server/src/database/commands/upgrade-version-command/2-20/2-20-workspace-command-1783525261001-create-message-list-view.command.ts:151

              flatEntityToCreate: viewsToCreate,
              flatEntityToDelete: [],
              flatEntityToUpdate: [],
            },
            viewField: {
              flatEntityToCreate: viewFieldsToCreate,
              flatEntityToDelete: [],
              flatEntityToUpdate: [],
            },
          },
        },
      );

    if (result.status === 'fail') {
      this.logger.error(
        `Failed to create messageList view:\n${JSON.stringify(result, null, 2)}`,
      );

      throw new Error(
        `Failed to create messageList view for workspace ${workspaceId}`,
      );
    }

    this.logger.log(`Created messageList view for workspace ${workspaceId}`);
  }

  private resolveViewsToCreate({
    flatViewMaps,
    standardAllFlatEntityMaps,
  }: {
    flatViewMaps: WorkspaceCacheDataMap['flatViewMaps'];
    standardAllFlatEntityMaps: TwentyStandardAllFlatEntityMaps;
  }): FlatView[] {
    if (
      isDefined(
        flatViewMaps.byUniversalIdentifier[LIST_VIEW_UNIVERSAL_IDENTIFIER],
      )

View on GitHub (pinned to 1f5dd2bbd2)