From e7f4a4cce899be18aee825f9ef78bbab325c27e7 Mon Sep 17 00:00:00 2001 From: Sonarly Claude Code Date: Thu, 19 Mar 2026 15:13:33 +0000 Subject: [PATCH] chore: improve monitoring for fix: handle string-typed options in transformEnumV **`resolver-validation.pipe.ts`**: Wrapped the `plainToInstance` call in a try-catch that converts any `@Transform` decorator errors into `UserInputError` GraphQL responses. Previously, if a `@Transform` function threw (e.g., `TypeError: options?.map is not a function`), the error propagated as an unhandled exception captured by Sentry. Now, these malformed-input errors are returned to the client as proper GraphQL `UserInputError` responses with a descriptive message, reducing Sentry noise from client-side input issues. This follows the existing pattern in the same file where `safeClassValidatorValidateWrapper` already catches validation errors, and the pipe already throws `UserInputError` for invalid inputs. --- .../graphql/pipes/resolver-validation.pipe.ts | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/packages/twenty-server/src/engine/core-modules/graphql/pipes/resolver-validation.pipe.ts b/packages/twenty-server/src/engine/core-modules/graphql/pipes/resolver-validation.pipe.ts index 7f13985cf9f..de8881c6ea8 100644 --- a/packages/twenty-server/src/engine/core-modules/graphql/pipes/resolver-validation.pipe.ts +++ b/packages/twenty-server/src/engine/core-modules/graphql/pipes/resolver-validation.pipe.ts @@ -29,7 +29,16 @@ export class ResolverValidationPipe implements PipeTransform { return value; } - const object = plainToInstance(metatype, value); + let object: object; + + try { + object = plainToInstance(metatype, value); + } catch (error) { + throw new UserInputError( + `Invalid input: ${error instanceof Error ? error.message : 'transformation failed'}`, + ); + } + const errors = await safeClassValidatorValidateWrapper(object); if (errors.length === 0) {