{"record":{"id":"2086b41c3d4a2632","repo":"twentyhq/twenty","slug":"failed-to-add-reply-to-option-to-messageparticipan","errorCode":null,"errorMessage":"Failed to add REPLY_TO option to messageParticipant role field for workspace ${workspaceId}","messagePattern":"Failed to add REPLY_TO option to messageParticipant role field for workspace (.+?)","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/twenty-server/src/database/commands/upgrade-version-command/2-17/2-17-workspace-command-1801000001000-add-reply-to-message-participant-role-option.command.ts","lineNumber":84,"sourceCode":"    const validateAndBuildResult =\n      await this.workspaceMigrationValidateBuildAndRunService.validateBuildAndRunLegacyWorkspaceMigration(\n        {\n          isSystemBuild: true,\n          workspaceId,\n          applicationUniversalIdentifier:\n            twentyStandardFlatApplication.universalIdentifier,\n          allFlatEntityOperationByMetadataName: {\n            fieldMetadata: fieldMetadataOperations,\n          },\n        },\n      );\n\n    if (validateAndBuildResult.status === 'fail') {\n      this.logger.error(\n        `Failed to add REPLY_TO option to messageParticipant role field:\\n${JSON.stringify(validateAndBuildResult, null, 2)}`,\n      );\n\n      throw new Error(\n        `Failed to add REPLY_TO option to messageParticipant role field for workspace ${workspaceId}`,\n      );\n    }\n\n    this.logger.log(\n      `Successfully added REPLY_TO option to messageParticipant role field for workspace ${workspaceId}`,\n    );\n  }\n}\n","sourceCodeStart":66,"sourceCodeEnd":94,"githubUrl":"https://github.com/twentyhq/twenty/blob/1f5dd2bbd2a8da3419c8cfd52dd545c0024df1a6/packages/twenty-server/src/database/commands/upgrade-version-command/2-17/2-17-workspace-command-1801000001000-add-reply-to-message-participant-role-option.command.ts#L66-L94","documentation":"Thrown by the 2.17 command that adds the REPLY_TO option to the messageParticipant.role SELECT field when validateBuildAndRunLegacyWorkspaceMigration returns status 'fail'. The logger.error above prints the full result; the thrown error is workspace-scoped. The payload updates the role field's options array to include REPLY_TO.","triggerScenarios":"Running the 2.17 upgrade where the messageParticipant role field is not a SELECT, already contains REPLY_TO in a form that conflicts with the new option (duplicate value/color/label), or has options missing required keys the validator expects.","commonSituations":"Custom edit of the role field options; prior partial run that added REPLY_TO without required keys; standard seed drift; concurrent migration runs.","solutions":["Read the logger.error JSON to find the failing option and error code.","Inspect core.fieldMetadata for the messageParticipant role field; dedupe or repair its options array.","Ensure the role field type is SELECT and that no other migration is editing it concurrently.","Re-run the workspace upgrade."],"exampleFix":null,"handlingStrategy":"validation","validationCode":"// Confirm the messageParticipant role field is SELECT and does not already\n// contain a conflicting REPLY_TO option.\nconst role = await dataSource.query(`\n  SELECT \"type\", \"options\" FROM core.\"fieldMetadata\"\n  WHERE \"nameSingular\" = 'role'\n    AND \"objectMetadataId\" = (SELECT id FROM core.\"objectMetadata\" WHERE \"nameSingular\" = 'messageParticipant')\n`);\nif (role[0]?.type !== 'SELECT') throw new Error('role field is not SELECT');\nconst hasReplyTo = role[0]?.options?.some((o: any) => o.value === 'REPLY_TO');\nif (hasReplyTo) throw new Error('REPLY_TO already present; 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":["Dedupe SELECT option values before upgrade.","Never change a standard field's type manually.","Run upgrades with API mutations paused."],"tags":["migration","workspace-upgrade","metadata-validation","select-field","message-participant"],"backgroundTag":null,"analyzedSha":"1f5dd2bbd2a8da3419c8cfd52dd545c0024df1a6","analyzedAt":"2026-08-12T15:37:27.593Z","schemaVersion":2},"datasetVersion":"2026-08-12T18:17:37.767Z"}