twentyhq/twenty · error · Error

Failed to delete connectedAccount standard object for worksp

Error message

Failed to delete connectedAccount standard object for workspace ${workspaceId}

What it means

Thrown by the 2.7 command that drops the connectedAccount standard object (and its relation fields). It submits the object/field delete operations via validateBuildAndRunLegacyWorkspaceMigration; on status === 'fail' it logs the report and throws. The report shows which object/field delete was blocked.

Source

Thrown at packages/twenty-server/src/database/commands/upgrade-version-command/2-7/2-7-workspace-command-1798000040000-drop-connected-account-standard-object.command.ts:136

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

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

      throw new Error(
        `Failed to delete connectedAccount standard object for workspace ${workspaceId}`,
      );
    }

    this.logger.log(
      `Deleted connectedAccount standard object and relation fields for workspace ${workspaceId}`,
    );
  }
}

View on GitHub (pinned to 1f5dd2bbd2)

Solutions

  1. Read the logged JSON report to identify the blocking dependency (relation/view/field).
  2. Remove or reassign the dependent relation/view/field rows for connectedAccount.
  3. Re-run the 2.7 command; if the object is already gone, mark the workspace handled.
Defensive patterns

Strategy: validation

Validate before calling

// Confirm no live relations still reference connectedAccount before dropping:
const refs = Object.values(flatRelationMetadataMaps.byId).filter(r => r.fromObjectMetadataUniversalIdentifier === CONNECTED_ACCOUNT_UI || r.toObjectMetadataUniversalIdentifier === CONNECTED_ACCOUNT_UI);
if (refs.length > 0) { /* drop or reassign them first */ }

Try / catch

try {
  await command.runOnWorkspace({ workspaceId, options });
} catch (e) {
  logger.error({ workspaceId, err: e.message }, 'connectedAccount drop failed');
}

Prevention

When it happens

Trigger: The connectedAccount object is referenced by a still-existing relation, view, or custom field on another object (cascade blocked); connectedAccount was already removed in a prior run so the delete targets nothing; a workspace has custom records/relations pointing at connectedAccount that prevent the drop.

Common situations: A prior interrupted 2.7 run; custom relations built on connectedAccount before it was deprecated; cross-version upgrade skipping the command that cleans up dependent relations first.

Related errors


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