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.22 command that backfills imageIdentifierFieldMetadataUniversalIdentifier on company (domainName) and person (avatarFile) objects. After computing which objects need the update (unset or pointing at deprecated field), the command calls validateBuildAndRunWorkspaceMigration with objectMetadata update operations. If the pipeline fails, the result is logged to logger.error and the generic error is thrown.
Source
Thrown at packages/twenty-server/src/database/commands/upgrade-version-command/2-22/2-22-workspace-command-1783959648000-backfill-company-person-image-identifier-field-metadata-id.command.ts:164
objectMetadata: {
flatEntityToCreate: [],
flatEntityToDelete: [],
flatEntityToUpdate: flatObjectMetadataToUpdate,
},
},
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 ${flatObjectMetadataToUpdate
.map((flatObjectMetadata) => flatObjectMetadata.nameSingular)
.join(', ')} for workspace ${workspaceId}`,
);
}
}
View on GitHub (pinned to 1f5dd2bbd2)
Solutions
- Read the logger.error output for JSON.stringify(validateAndBuildResult) containing the specific failure report
- Flush flatObjectMetadataMaps and flatFieldMetadataMaps from workspace cache, then retry
- Verify the target fields exist: check flatFieldMetadataMaps for domainName (company) and avatarFile (person) universal identifiers
- Run with --dryRun to inspect the planned updates
Defensive patterns
Strategy: retry
Validate before calling
// Before running, verify the target fields exist in the workspace cache
const { flatFieldMetadataMaps, flatObjectMetadataMaps } =
await workspaceCacheService.getOrRecompute(workspaceId, [
'flatFieldMetadataMaps',
'flatObjectMetadataMaps',
]);
const hasDomainName = isDefined(
flatFieldMetadataMaps.byUniversalIdentifier[
STANDARD_OBJECTS.company.fields.domainName.universalIdentifier
]
);
const hasAvatarFile = isDefined(
flatFieldMetadataMaps.byUniversalIdentifier[
STANDARD_OBJECTS.person.fields.avatarFile.universalIdentifier
]
);
if (!hasDomainName && !hasAvatarFile) {
console.log('No target fields exist — nothing to backfill');
} Try / catch
// Retry after flushing cache
try {
await command.runOnWorkspace({ workspaceId, options: { dryRun: false } });
} catch (error) {
if (error.message.includes('Failed to backfill imageIdentifierFieldMetadataId')) {
await workspaceCacheService.flush(workspaceId, ['flatObjectMetadataMaps', 'flatFieldMetadataMaps']);
await command.runOnWorkspace({ workspaceId, options: { dryRun: false } });
} else {
throw error;
}
} Prevention
- Run with --dryRun first — the command already skips objects/fields that don't exist
- Flush flatObjectMetadataMaps and flatFieldMetadataMaps before retrying
- Parse the logger.error JSON for the specific objectMetadata validation failure
- Ensure no concurrent workspace modifications during the upgrade
When it happens
Trigger: validateBuildAndRunWorkspaceMigration returns status 'fail' when updating objectMetadata rows to set imageIdentifierFieldMetadataUniversalIdentifier. Caused by: the referenced field universal identifier not existing as a FlatFieldMetadata in the workspace, the object not existing in workspace metadata, stale cache, or a DB error.
Common situations: The domainName or avatarFile field was deleted or never created on the workspace; workspace cache has stale flatFieldMetadataMaps that do not reflect the actual DB state; a prior upgrade partially modified the object metadata.
Related errors
- Failed to create searchVector GIN index(es) for workspace ${
- Failed to create searchFieldMetadata row(s) for workspace ${
- Failed to add coreWorkflowVersionId field for workspace ${wo
- Failed to add coreWorkflowId field for workspace ${workspace
- Failed to fix "Go to Roles Settings" command menu item path
AI-assisted analysis of twentyhq/twenty@1f5dd2bbd2 (2026-08-12).
Data as JSON: /api/errors/930790122a83e074.
Report an issue: GitHub.