twentyhq/twenty · error · Error
Failed to create Message isDraft field for workspace ${works
Error message
Failed to create Message isDraft field for workspace ${workspaceId} What it means
Thrown by the 2.18 command that creates the Message.isDraft field when validateAndBuildResult.status === 'fail'. The logger.error above prints the full result. The standard seed check (error 130) has already passed, so this is a build-phase rejection of the create payload for the workspace.
Source
Thrown at packages/twenty-server/src/database/commands/upgrade-version-command/2-18/2-18-workspace-command-1810000005000-add-message-is-draft-field.command.ts:135
flatEntityToUpdate: [],
},
},
workspaceId,
applicationUniversalIdentifier:
twentyStandardFlatApplication.universalIdentifier,
},
);
if (validateAndBuildResult.status === 'fail') {
this.logger.error(
`Failed to create Message isDraft field:\n${JSON.stringify(
validateAndBuildResult,
null,
2,
)}`,
);
throw new Error(
`Failed to create Message isDraft field for workspace ${workspaceId}`,
);
}
this.logger.log(
`Created Message isDraft field for workspace ${workspaceId}`,
);
}
}
View on GitHub (pinned to 1f5dd2bbd2)
Solutions
- Read the logger.error JSON to identify the failing validation code and entity.
- Inspect core.fieldMetadata for an existing isDraft field on the Message object; remove or reconcile if conflicting.
- Confirm the Message object exists and matches the standard seed.
- Re-run the workspace upgrade.
Defensive patterns
Strategy: validation
Validate before calling
// Confirm no conflicting isDraft field on Message before the create.
const existing = await dataSource.query(`
SELECT id FROM core."fieldMetadata"
WHERE "nameSingular" = 'isDraft'
AND "objectMetadataId" = (SELECT id FROM core."objectMetadata" WHERE "nameSingular" = 'message')
`);
if (existing.length) throw new Error('isDraft already exists on Message; reconcile before upgrade'); Type guard
function isFailResult(r: unknown): r is { status: 'fail' } {
return typeof r === 'object' && r !== null && (r as any).status === 'fail';
} Try / catch
try {
const res = await service.validateBuildAndRunLegacyWorkspaceMigration(payload);
if (res.status === 'fail') throw new Error(`... for workspace ${workspaceId}`);
} catch (err) { upgradeAudit.record(workspaceId, command.id, err); throw err; } Prevention
- Detect pre-existing custom fields sharing standard universal identifiers before upgrade.
- Run upgrades with API mutations paused.
- Verify the Message object matches the standard seed.
When it happens
Trigger: Running the 2.18 upgrade on a workspace where the Message object is missing/inconsistent, where an isDraft field already exists in a conflicting state, or where the create payload fails schema validation. The standard seed exists (130 passed) but the workspace cannot accept it.
Common situations: Workspace with a custom isDraft field already on Message; prior partial run leaving a half-created row; Message object drifted from standard; concurrent migrations.
Related errors
- Migration failed for workspace ${workspaceId} while healing
- Failed to create CallRecording recordingRequestStatus metada
- Failed to delete CalendarEvent recordingPreference field for
- Failed to create CalendarEvent record page metadata for work
- Failed to persist searchFieldMetadata rows for workspace ${w
AI-assisted analysis of twentyhq/twenty@1f5dd2bbd2 (2026-08-12).
Data as JSON: /api/errors/146f014808f6ea66.
Report an issue: GitHub.