From ee6c9db33a560f5801f2184f654cb6aa5a272388 Mon Sep 17 00:00:00 2001 From: Charles Bochet Date: Tue, 16 Jun 2026 12:02:25 +0200 Subject: [PATCH] fix(server): surface validation errors in 2-14 fix-standard-relation-field-labels-icons upgrade command (#21658) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ## Problem The \`2-14:fix-standard-relation-field-labels-icons\` workspace upgrade command threw a generic error on migration build failure: \`\`\`ts if (result.status === 'fail') { throw new Error(\`Migration failed for workspace \${workspaceId} while healing standard relation field labels/icons\`); } \`\`\` This discarded \`result.report\` entirely — the structured per-field validation failures (\`code\`, \`message\`, \`value\`, offending field) — making real-world upgrade failures impossible to diagnose from logs. On a recent staging/app-main upgrade, 13 workspaces failed here with no actionable detail. ## Change Flatten \`result.report\` into both the logged error and the thrown message, so failures now print the actual validation errors per field, e.g.: \`\`\` [fieldMetadata] -> SOME_VALIDATION_CODE: \`\`\` No behavior change beyond logging/error content — the command still aborts on failure as before. ## Notes - Dry-run still returns before the build step, so this only surfaces on real runs (unchanged). Review in cubic --- ...ndard-relation-field-labels-icons.command.ts | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/packages/twenty-server/src/database/commands/upgrade-version-command/2-14/2-14-workspace-command-1799000040000-fix-standard-relation-field-labels-icons.command.ts b/packages/twenty-server/src/database/commands/upgrade-version-command/2-14/2-14-workspace-command-1799000040000-fix-standard-relation-field-labels-icons.command.ts index 8eaed28eb7..6a4dc76232 100644 --- a/packages/twenty-server/src/database/commands/upgrade-version-command/2-14/2-14-workspace-command-1799000040000-fix-standard-relation-field-labels-icons.command.ts +++ b/packages/twenty-server/src/database/commands/upgrade-version-command/2-14/2-14-workspace-command-1799000040000-fix-standard-relation-field-labels-icons.command.ts @@ -136,8 +136,23 @@ export class FixStandardRelationFieldLabelsIconsCommand extends ActiveOrSuspende ); if (result.status === 'fail') { + const failureDetails = Object.values(result.report) + .flat() + .map((failedValidation) => { + const errorMessages = failedValidation.errors + .map((error) => `${error.code}: ${error.message}`) + .join('; '); + + return `[${failedValidation.metadataName}] ${failedValidation.flatEntityMinimalInformation.universalIdentifier ?? failedValidation.flatEntityMinimalInformation.id ?? 'unknown'} -> ${errorMessages}`; + }) + .join('\n'); + + this.logger.error( + `Migration build failed for workspace ${workspaceId} while healing standard relation field labels/icons:\n${failureDetails}`, + ); + throw new Error( - `Migration failed for workspace ${workspaceId} while healing standard relation field labels/icons`, + `Migration failed for workspace ${workspaceId} while healing standard relation field labels/icons:\n${failureDetails}`, ); }