{"record":{"id":"146f014808f6ea66","repo":"twentyhq/twenty","slug":"failed-to-create-message-isdraft-field-for-workspa","errorCode":null,"errorMessage":"Failed to create Message isDraft field for workspace ${workspaceId}","messagePattern":"Failed to create Message isDraft field for workspace (.+?)","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/twenty-server/src/database/commands/upgrade-version-command/2-18/2-18-workspace-command-1810000005000-add-message-is-draft-field.command.ts","lineNumber":135,"sourceCode":"              flatEntityToUpdate: [],\n            },\n          },\n          workspaceId,\n          applicationUniversalIdentifier:\n            twentyStandardFlatApplication.universalIdentifier,\n        },\n      );\n\n    if (validateAndBuildResult.status === 'fail') {\n      this.logger.error(\n        `Failed to create Message isDraft field:\\n${JSON.stringify(\n          validateAndBuildResult,\n          null,\n          2,\n        )}`,\n      );\n\n      throw new Error(\n        `Failed to create Message isDraft field for workspace ${workspaceId}`,\n      );\n    }\n\n    this.logger.log(\n      `Created Message isDraft field for workspace ${workspaceId}`,\n    );\n  }\n}\n","sourceCodeStart":117,"sourceCodeEnd":145,"githubUrl":"https://github.com/twentyhq/twenty/blob/1f5dd2bbd2a8da3419c8cfd52dd545c0024df1a6/packages/twenty-server/src/database/commands/upgrade-version-command/2-18/2-18-workspace-command-1810000005000-add-message-is-draft-field.command.ts#L117-L145","documentation":"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.","triggerScenarios":"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.","commonSituations":"Workspace with a custom isDraft field already on Message; prior partial run leaving a half-created row; Message object drifted from standard; concurrent migrations.","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."],"exampleFix":null,"handlingStrategy":"validation","validationCode":"// Confirm no conflicting isDraft field on Message before the create.\nconst existing = await dataSource.query(`\n  SELECT id FROM core.\"fieldMetadata\"\n  WHERE \"nameSingular\" = 'isDraft'\n    AND \"objectMetadataId\" = (SELECT id FROM core.\"objectMetadata\" WHERE \"nameSingular\" = 'message')\n`);\nif (existing.length) throw new Error('isDraft already exists on Message; reconcile before upgrade');","typeGuard":"function isFailResult(r: unknown): r is { status: 'fail' } {\n  return typeof r === 'object' && r !== null && (r as any).status === 'fail';\n}","tryCatchPattern":"try {\n  const res = await service.validateBuildAndRunLegacyWorkspaceMigration(payload);\n  if (res.status === 'fail') throw new Error(`... for workspace ${workspaceId}`);\n} catch (err) { upgradeAudit.record(workspaceId, command.id, err); throw err; }","preventionTips":["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."],"tags":["migration","workspace-upgrade","metadata-validation","message"],"backgroundTag":null,"analyzedSha":"1f5dd2bbd2a8da3419c8cfd52dd545c0024df1a6","analyzedAt":"2026-08-12T15:37:27.593Z","schemaVersion":2},"datasetVersion":"2026-08-12T23:17:12.415Z"}