twentyhq/twenty · error · Error

Failed to add jobTitle field on workspaceMember for workspac

Error message

Failed to add jobTitle field on workspaceMember for workspace ${workspaceId}

What it means

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.

Source

Thrown at packages/twenty-server/src/database/commands/upgrade-version-command/2-17/2-17-workspace-command-1801000010000-add-workspace-member-job-title-field.command.ts:144

            },
          },
          workspaceId,
          isSystemBuild: true,
          applicationUniversalIdentifier:
            twentyStandardFlatApplication.universalIdentifier,
        },
      );

    if (validateAndBuildResult.status === 'fail') {
      this.logger.error(
        `Failed to add jobTitle field on workspaceMember for workspace ${workspaceId}:\n${JSON.stringify(
          validateAndBuildResult,
          null,
          2,
        )}`,
      );

      throw new Error(
        `Failed to add jobTitle field on workspaceMember for workspace ${workspaceId}`,
      );
    }

    this.logger.log(
      `Added jobTitle field on workspaceMember for workspace ${workspaceId}`,
    );
  }
}

View on GitHub (pinned to 1f5dd2bbd2)

Solutions

  1. Read the logger.error JSON to find the failing field and error code.
  2. Inspect core.fieldMetadata for an existing jobTitle field on the workspaceMember object; if present and conflicting, remove or reconcile it.
  3. Confirm the workspaceMember object exists and matches the standard seed.
  4. Re-run the workspace upgrade.
Defensive patterns

Strategy: validation

Validate before calling

// Confirm no conflicting jobTitle field already exists on workspaceMember.
const existing = await dataSource.query(`
  SELECT id FROM core."fieldMetadata"
  WHERE "nameSingular" = 'jobTitle'
    AND "objectMetadataId" = (SELECT id FROM core."objectMetadata" WHERE "nameSingular" = 'workspaceMember')
`);
if (existing.length) throw new Error('jobTitle already exists on workspaceMember; 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

When it happens

Trigger: 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).

Common situations: Workspace that already has a custom jobTitle field on workspaceMember; prior partial run leaving a half-created jobTitle row; standard seed drift; concurrent migrations.

Related errors


AI-assisted analysis of twentyhq/twenty@1f5dd2bbd2 (2026-08-12). Data as JSON: /api/errors/764b2385f08cc1a0. Report an issue: GitHub.