{"record":{"id":"764b2385f08cc1a0","repo":"twentyhq/twenty","slug":"failed-to-add-jobtitle-field-on-workspacemember-fo","errorCode":null,"errorMessage":"Failed to add jobTitle field on workspaceMember for workspace ${workspaceId}","messagePattern":"Failed to add jobTitle field on workspaceMember 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-1801000010000-add-workspace-member-job-title-field.command.ts","lineNumber":144,"sourceCode":"            },\n          },\n          workspaceId,\n          isSystemBuild: true,\n          applicationUniversalIdentifier:\n            twentyStandardFlatApplication.universalIdentifier,\n        },\n      );\n\n    if (validateAndBuildResult.status === 'fail') {\n      this.logger.error(\n        `Failed to add jobTitle field on workspaceMember for workspace ${workspaceId}:\\n${JSON.stringify(\n          validateAndBuildResult,\n          null,\n          2,\n        )}`,\n      );\n\n      throw new Error(\n        `Failed to add jobTitle field on workspaceMember for workspace ${workspaceId}`,\n      );\n    }\n\n    this.logger.log(\n      `Added jobTitle field on workspaceMember for workspace ${workspaceId}`,\n    );\n  }\n}\n","sourceCodeStart":126,"sourceCodeEnd":154,"githubUrl":"https://github.com/twentyhq/twenty/blob/1f5dd2bbd2a8da3419c8cfd52dd545c0024df1a6/packages/twenty-server/src/database/commands/upgrade-version-command/2-17/2-17-workspace-command-1801000010000-add-workspace-member-job-title-field.command.ts#L126-L154","documentation":"Thrown by the 2.17 command that adds the jobTitle field to the workspaceMember object when validateAndBuildResult.status === 'fail'. The logger.error above prints the full result (note: the thrown error and the log line include the same workspace context). The payload creates a new fieldMetadata row on workspaceMember.","triggerScenarios":"Running the 2.17 upgrade where the workspaceMember object is missing/inconsistent, where a jobTitle field already exists in a state the validator rejects as a conflict, or where the fieldMetadata payload fails schema validation (bad type, missing required keys).","commonSituations":"Workspace that already has a custom jobTitle field on workspaceMember; prior partial run leaving a half-created jobTitle row; standard seed drift; concurrent migrations.","solutions":["Read the logger.error JSON to find the failing field and error code.","Inspect core.fieldMetadata for an existing jobTitle field on the workspaceMember object; if present and conflicting, remove or reconcile it.","Confirm the workspaceMember object exists and matches the standard seed.","Re-run the workspace upgrade."],"exampleFix":null,"handlingStrategy":"validation","validationCode":"// Confirm no conflicting jobTitle field already exists on workspaceMember.\nconst existing = await dataSource.query(`\n  SELECT id FROM core.\"fieldMetadata\"\n  WHERE \"nameSingular\" = 'jobTitle'\n    AND \"objectMetadataId\" = (SELECT id FROM core.\"objectMetadata\" WHERE \"nameSingular\" = 'workspaceMember')\n`);\nif (existing.length) throw new Error('jobTitle already exists on workspaceMember; 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.","Keep workspaceMember object aligned to the standard seed."],"tags":["migration","workspace-upgrade","metadata-validation","workspace-member"],"backgroundTag":null,"analyzedSha":"1f5dd2bbd2a8da3419c8cfd52dd545c0024df1a6","analyzedAt":"2026-08-12T15:37:27.593Z","schemaVersion":2},"datasetVersion":"2026-08-12T18:17:37.767Z"}