twentyhq/twenty · error · Error

Failed to backfill imageIdentifierFieldMetadataId for worksp

Error message

Failed to backfill imageIdentifierFieldMetadataId for workspace ${workspaceId}

What it means

Thrown by the 2.3 command that backfills imageIdentifierFieldMetadataId on the workspaceMember object. It runs the field-metadata update via validateBuildAndRunLegacyWorkspaceMigration (isSystemBuild: true); on status === 'fail' it logs the report and throws. The failure is in validating/applying the workspaceMember field update that stores the image field reference.

Source

Thrown at packages/twenty-server/src/database/commands/upgrade-version-command/2-3/2-3-workspace-command-1777920000000-backfill-image-identifier-field-metadata-id.command.ts:130

                  imageIdentifierFieldMetadataUniversalIdentifier:
                    AVATAR_URL_FIELD_UNIVERSAL_IDENTIFIER,
                },
              ],
            },
          },
          workspaceId,
          isSystemBuild: true,
          applicationUniversalIdentifier:
            twentyStandardFlatApplication.universalIdentifier,
        },
      );

    if (validateAndBuildResult.status === 'fail') {
      this.logger.error(
        `Failed to backfill imageIdentifierFieldMetadataId for workspace ${workspaceId}:\n${JSON.stringify(validateAndBuildResult, null, 2)}`,
      );

      throw new Error(
        `Failed to backfill imageIdentifierFieldMetadataId for workspace ${workspaceId}`,
      );
    }

    this.logger.log(
      `Backfilled imageIdentifierFieldMetadataId on workspaceMember for workspace ${workspaceId}`,
    );
  }
}

View on GitHub (pinned to 1f5dd2bbd2)

Solutions

  1. Inspect the logged JSON report for the failing field and error code.
  2. Ensure the workspaceMember image field exists and is active (re-seed it if missing).
  3. Clear any stale imageIdentifierFieldMetadataId value, then re-run the 2.3 command.
Defensive patterns

Strategy: validation

Validate before calling

// Confirm the image field referenced exists on workspaceMember:
const imageField = flatFieldMetadataMaps.byUniversalIdentifier[WORKSPACE_MEMBER_IMAGE_UI];
if (!isDefined(imageField)) { /* seed it first */ }

Try / catch

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

Prevention

When it happens

Trigger: The image field referenced by imageIdentifierFieldMetadataId does not exist on workspaceMember; the workspaceMember object is absent or deactivated; the referenced field id is a dangling FK (field was soft-deleted); the column already holds a value failing a uniqueness/format check.

Common situations: Workspace on an old release where the workspaceMember image field was never seeded or was removed; cross-version upgrade skipping the command that creates the image field; soft-deleted field metadata leaving a stale id.

Related errors


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