Compare commits

...
Author SHA1 Message Date
Sonarly Claude CodeandClaude Opus 4.6 2fb5d07bd3 fix: handle EntityMetadataNotFoundError as a GraphQL NotFoundError
When a workspace object's TypeORM entity metadata is not found (e.g., due
to cache desync after creating/deleting custom objects), the raw TypeORM
EntityMetadataNotFoundError was propagating unhandled through the GraphQL
resolver, causing a 500 error reported to Sentry.

This adds handling for EntityMetadataNotFoundError in the workspace query
runner exception handler, converting it to a proper GraphQL NOT_FOUND
error that is returned gracefully to the client.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-18 16:49:40 +00:00
@@ -1,4 +1,5 @@
import { type QueryFailedError } from 'typeorm';
import { EntityMetadataNotFoundError } from 'typeorm/error/EntityMetadataNotFoundError';
import { CommonQueryRunnerException } from 'src/engine/api/common/common-query-runners/errors/common-query-runner.exception';
import { commonQueryRunnerToGraphqlApiExceptionHandler } from 'src/engine/api/common/common-query-runners/utils/common-query-runner-to-graphql-api-exception-handler.util';
@@ -10,6 +11,7 @@ import { ApiKeyException } from 'src/engine/core-modules/api-key/exceptions/api-
import { apiKeyGraphqlApiExceptionHandler } from 'src/engine/core-modules/api-key/utils/api-key-graphql-api-exception-handler.util';
import { AuthException } from 'src/engine/core-modules/auth/auth.exception';
import { authGraphqlApiExceptionHandler } from 'src/engine/core-modules/auth/utils/auth-graphql-api-exception-handler.util';
import { NotFoundError } from 'src/engine/core-modules/graphql/utils/graphql-errors.util';
import { RecordTransformerException } from 'src/engine/core-modules/record-transformer/record-transformer.exception';
import { recordTransformerGraphqlApiExceptionHandler } from 'src/engine/core-modules/record-transformer/utils/record-transformer-graphql-api-exception-handler.util';
import { ThrottlerException } from 'src/engine/core-modules/throttler/throttler.exception';
@@ -45,6 +47,8 @@ export const workspaceQueryRunnerGraphqlApiExceptionHandler = (
return apiKeyGraphqlApiExceptionHandler(error);
case error instanceof ThrottlerException:
return throttlerToGraphqlApiExceptionHandler(error);
case error instanceof EntityMetadataNotFoundError:
throw new NotFoundError(error.message);
default:
throw error;
}