From 9cd957844e74bb9bcfcdf41fdc1f355b8fa38b7e Mon Sep 17 00:00:00 2001 From: RaphiTobi Date: Fri, 17 Oct 2025 14:33:33 +0200 Subject: [PATCH] Log invalid uuids (#15099) I had an issue with invalid UUIDs, and I think it would be easier to find the offending one if the UUID were included in the error message. This way a database dump can be easily searched. --------- Co-authored-by: prastoin --- .../graphql-types/scalars/uuid.scalar.ts | 4 +++- .../engine/core-modules/graphql/utils/graphql-errors.util.ts | 4 ++-- ...ailing-update-one-object-metadata.integration-spec.ts.snap | 1 + 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/packages/twenty-server/src/engine/api/graphql/workspace-schema-builder/graphql-types/scalars/uuid.scalar.ts b/packages/twenty-server/src/engine/api/graphql/workspace-schema-builder/graphql-types/scalars/uuid.scalar.ts index acec37607f6..6a2513b8971 100644 --- a/packages/twenty-server/src/engine/api/graphql/workspace-schema-builder/graphql-types/scalars/uuid.scalar.ts +++ b/packages/twenty-server/src/engine/api/graphql/workspace-schema-builder/graphql-types/scalars/uuid.scalar.ts @@ -9,7 +9,9 @@ const checkUUID = (value: any): string => { throw new ValidationError('UUID must be a string'); } if (!uuidValidate(value)) { - throw new ValidationError('Invalid UUID'); + throw new ValidationError(`Invalid UUID`, { + value, + }); } return value; diff --git a/packages/twenty-server/src/engine/core-modules/graphql/utils/graphql-errors.util.ts b/packages/twenty-server/src/engine/core-modules/graphql/utils/graphql-errors.util.ts index e59d61f79f6..f108abee9eb 100644 --- a/packages/twenty-server/src/engine/core-modules/graphql/utils/graphql-errors.util.ts +++ b/packages/twenty-server/src/engine/core-modules/graphql/utils/graphql-errors.util.ts @@ -122,8 +122,8 @@ export class SyntaxError extends BaseGraphQLError { } export class ValidationError extends BaseGraphQLError { - constructor(message: string) { - super(message, ErrorCode.GRAPHQL_VALIDATION_FAILED); + constructor(message: string, extensions?: BaseGraphQLError['extensions']) { + super(message, ErrorCode.GRAPHQL_VALIDATION_FAILED, extensions); Object.defineProperty(this, 'name', { value: 'ValidationError' }); } diff --git a/packages/twenty-server/test/integration/metadata/suites/object-metadata/__snapshots__/failing-update-one-object-metadata.integration-spec.ts.snap b/packages/twenty-server/test/integration/metadata/suites/object-metadata/__snapshots__/failing-update-one-object-metadata.integration-spec.ts.snap index 178f1f8eeee..140c563ef03 100644 --- a/packages/twenty-server/test/integration/metadata/suites/object-metadata/__snapshots__/failing-update-one-object-metadata.integration-spec.ts.snap +++ b/packages/twenty-server/test/integration/metadata/suites/object-metadata/__snapshots__/failing-update-one-object-metadata.integration-spec.ts.snap @@ -164,6 +164,7 @@ exports[`Object metadata update should fail when labelIdentifier is not a uuid 1 "status": 400, }, "userFriendlyMessage": "An error occurred.", + "value": "not-a-uuid", }, "message": "Invalid UUID", "name": "ValidationError",