twentyhq/twenty · error · Error

Failed to create custom object page layouts for workspace ${

Error message

Failed to create custom object page layouts for workspace ${workspaceId}

What it means

Thrown inside the 1.23 backfill command's custom-object-layout create step when validateBuildAndRunLegacyWorkspaceMigration returns 'fail' while creating page layouts for custom objects. The result JSON is logged first; this is the final step of the command so the throw ends the workspace run.

Source

Thrown at packages/twenty-server/src/database/commands/upgrade-version-command/1-23/1-23-workspace-command-1780000001500-backfill-record-page-layouts.command.ts:591

              flatEntityToUpdate: [],
            },
            viewField: {
              flatEntityToCreate: allViewFields,
              flatEntityToDelete: [],
              flatEntityToUpdate: [],
            },
          },
          workspaceId,
          applicationUniversalIdentifier:
            twentyStandardFlatApplication.universalIdentifier,
        },
      );

    if (result.status === 'fail') {
      this.logger.error(
        `Failed to create custom object page layouts:\n${JSON.stringify(result, null, 2)}`,
      );
      throw new Error(
        `Failed to create custom object page layouts for workspace ${workspaceId}`,
      );
    }
  }
}

View on GitHub (pinned to 1f5dd2bbd2)

Solutions

  1. Read the logged result JSON for the precise rejection.
  2. Recompute the workspace cache and retry.
  3. Run --dryRun to inspect planned custom-object layouts.
  4. Reconcile any deleted custom objects in the failing workspace.
Defensive patterns

Strategy: validation

Validate before calling

// Dry-run to preview custom-object layouts, and confirm custom objects exist in cache:
await workspaceCacheService.invalidate(workspaceId);
const { flatObjectMetadataMaps } = await workspaceCacheService.getOrRecompute(workspaceId, ['flatObjectMetadataMaps']);
const customObjects = Object.values(flatObjectMetadataMaps.byUniversalIdentifier).filter((o) => isDefined(o) && o.isCustom);
if (customObjects.length === 0) throw new Error('No custom objects found; nothing to create layouts for');

Try / catch

try {
  await command.runOnWorkspace({ workspaceId, options });
} catch (err) {
  logger.error(`Custom object page layout create failed for workspace ${workspaceId}`, err);
  failedWorkspaces.push(workspaceId);
}

Prevention

When it happens

Trigger: Running the 1.23 backfill on a workspace whose custom objects are missing from cache or whose layout batch duplicates existing custom-object layouts the validator rejects.

Common situations: Stale cache missing custom objects; partial prior run created some custom layouts already; custom object referenced by the layout was deleted mid-upgrade.

Related errors


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