twentyhq/twenty · critical · Error
Workspace custom application not found for workspace ${works
Error message
Workspace custom application not found for workspace ${workspaceId} What it means
Thrown by the 2.23 command that rebuilds core workflow rows and links them via coreWorkflowId. The command opens a queryRunner, runs raw SQL to fetch databaseSchema and workspaceCustomApplicationId from core.workspace. If workspaceCustomApplicationId is null or the workspace row is absent, the command throws because it needs the application ID to INSERT core workflow rows.
Source
Thrown at packages/twenty-server/src/database/commands/upgrade-version-command/2-23/2-23-workspace-command-1784286707000-backfill-workflow-core-links.command.ts:84
this.logger.log(
`[DRY RUN] Would rebuild ${workspaceWorkflows.length} core workflow row(s) for workspace ${workspaceId}`,
);
return;
}
const queryRunner = dataSource.createQueryRunner();
await queryRunner.connect();
try {
const [workspace] = await queryRunner.query(
`SELECT "databaseSchema", "workspaceCustomApplicationId" FROM core."workspace" WHERE id = $1`,
[workspaceId],
);
if (!isDefined(workspace?.workspaceCustomApplicationId)) {
throw new Error(
`Workspace custom application not found for workspace ${workspaceId}`,
);
}
const schema: string = workspace.databaseSchema;
const applicationId: string = workspace.workspaceCustomApplicationId;
await queryRunner.startTransaction();
try {
await queryRunner.query(
`DELETE FROM core."workflow" WHERE "workspaceId" = $1`,
[workspaceId],
);
for (const workflow of workspaceWorkflows) {
const coreWorkflowId = uuidv4();
View on GitHub (pinned to 1f5dd2bbd2)
Solutions
- Verify the workspace row: SELECT id, "workspaceCustomApplicationId" FROM core."workspace" WHERE id = $workspaceId
- If workspaceCustomApplicationId is null, restore it from the application table or re-provision the workspace
- Exclude deleted/suspended workspaces from the upgrade iterator
- Check provisioning logs for the workspace
Example fix
// before: throws if workspaceCustomApplicationId is null
if (!isDefined(workspace?.workspaceCustomApplicationId)) {
throw new Error(`Workspace custom application not found for workspace ${workspaceId}`);
}
// after: skip gracefully
if (!isDefined(workspace?.workspaceCustomApplicationId)) {
this.logger.warn(`Workspace ${workspaceId} has no custom application, skipping core link backfill`);
return;
} Defensive patterns
Strategy: validation
Validate before calling
// Before running the upgrade, verify the workspace has a custom application
const result = await dataSource.query(
`SELECT id, "workspaceCustomApplicationId" FROM core."workspace" WHERE id = $1`,
[workspaceId],
);
if (!result[0] || !result[0].workspaceCustomApplicationId) {
console.error(`Workspace ${workspaceId} has no custom application — skip or re-provision`);
} Type guard
import { isDefined } from 'twenty-shared/utils';
const hasCustomApplication = (
workspace: { workspaceCustomApplicationId: string | null } | undefined,
): workspace is { workspaceCustomApplicationId: string } =>
isDefined(workspace) && isDefined(workspace.workspaceCustomApplicationId); Prevention
- Verify workspace provisioning completed before running upgrade commands
- Exclude workspaces in deleted/suspended states from the upgrade iterator
- Run a pre-upgrade check for NULL workspaceCustomApplicationId values
- Monitor workspace provisioning for failures
When it happens
Trigger: The workspaceId has no row in core.workspace, or the row's workspaceCustomApplicationId is null. Workspace provisioning never created the custom application, or it was removed.
Common situations: Incomplete workspace provisioning; workspace in a deleted/suspended state; manual DB modification; testing against a non-existent workspace ID.
Related errors
- Workspace custom application not found for workspace ${works
- Standard application is missing workflowVersion field coreWo
- Failed to add coreWorkflowVersionId field for workspace ${wo
- Standard application is missing workflow field coreWorkflowI
- Failed to add coreWorkflowId field for workspace ${workspace
AI-assisted analysis of twentyhq/twenty@1f5dd2bbd2 (2026-08-12).
Data as JSON: /api/errors/fddea007dfde0f57.
Report an issue: GitHub.