Fix unclear metadata validation errors (#20234)

https://github.com/user-attachments/assets/8f8f1122-3de1-4a9b-8bb4-a3c8d31e47ae

---------

Co-authored-by: Cursor <cursoragent@cursor.com>
Co-authored-by: Charles Bochet <charles@twenty.com>
This commit is contained in:
Abdul Rahman
2026-05-05 23:48:05 +05:30
committed by GitHub
parent a03c2647cf
commit e0563377b5
70 changed files with 935 additions and 771 deletions
@@ -1,4 +1,3 @@
import { type I18n } from '@lingui/core';
import { assertUnreachable } from 'twenty-shared/utils';
import {
@@ -18,14 +17,11 @@ import {
PageLayoutExceptionCode,
} from 'src/engine/metadata-modules/page-layout/exceptions/page-layout.exception';
import { WorkspaceMigrationBuilderException } from 'src/engine/workspace-manager/workspace-migration/exceptions/workspace-migration-builder-exception';
import { workspaceMigrationBuilderExceptionFormatter } from 'src/engine/workspace-manager/workspace-migration/interceptors/workspace-migration-builder-exception-formatter';
import { workspaceMigrationBuilderGraphqlApiExceptionHandler } from 'src/engine/workspace-manager/workspace-migration/interceptors/utils/workspace-migration-builder-graphql-api-exception-handler.util';
export const pageLayoutGraphqlApiExceptionHandler = (
error: Error,
i18n: I18n,
) => {
export const pageLayoutGraphqlApiExceptionHandler = (error: Error) => {
if (error instanceof WorkspaceMigrationBuilderException) {
return workspaceMigrationBuilderExceptionFormatter(error, i18n);
return workspaceMigrationBuilderGraphqlApiExceptionHandler(error);
}
if (error instanceof PageLayoutException) {
@@ -4,11 +4,7 @@ import {
type ExecutionContext,
Injectable,
} from '@nestjs/common';
import { GqlExecutionContext } from '@nestjs/graphql';
import { SOURCE_LOCALE } from 'twenty-shared/translations';
import { I18nService } from 'src/engine/core-modules/i18n/i18n.service';
import { PageLayoutTabException } from 'src/engine/metadata-modules/page-layout-tab/exceptions/page-layout-tab.exception';
import { PageLayoutWidgetException } from 'src/engine/metadata-modules/page-layout-widget/exceptions/page-layout-widget.exception';
import { PageLayoutException } from 'src/engine/metadata-modules/page-layout/exceptions/page-layout.exception';
@@ -23,21 +19,14 @@ import { WorkspaceMigrationBuilderException } from 'src/engine/workspace-manager
)
@Injectable()
export class PageLayoutGraphqlApiExceptionFilter implements ExceptionFilter {
constructor(private readonly i18nService: I18nService) {}
catch(
exception:
| PageLayoutException
| PageLayoutTabException
| PageLayoutWidgetException
| WorkspaceMigrationBuilderException,
host: ExecutionContext,
_host: ExecutionContext,
) {
const gqlContext = GqlExecutionContext.create(host);
const ctx = gqlContext.getContext();
const userLocale = ctx.req?.locale ?? SOURCE_LOCALE;
const i18n = this.i18nService.getI18nInstance(userLocale);
return pageLayoutGraphqlApiExceptionHandler(exception, i18n);
return pageLayoutGraphqlApiExceptionHandler(exception);
}
}