The open alternative to Salesforce, designed for AI.
TypeScript crmcrm-systemcustomergood-first-issuegraphqlhacktoberfestjavascriptmarketingmonoreponestjsopen-sourcepostgresqlreactreactjssalestypescriptweb
Fix messaging import (#16112)
Charles Bochetb1d1bcb71261
diff --git a/packages/twenty-server/src/modules/messaging/message-import-manager/drivers/gmail/services/gmail-messages-import-error-handler.service.ts b/packages/twenty-server/src/modules/messaging/message-import-manager/drivers/gmail/services/gmail-messages-import-error-handler.service.tsindex 9ab22c68174..569820634aa 100644--- a/packages/twenty-server/src/modules/messaging/message-import-manager/drivers/gmail/services/gmail-messages-import-error-handler.service.ts+++ b/packages/twenty-server/src/modules/messaging/message-import-manager/drivers/gmail/services/gmail-messages-import-error-handler.service.ts@@ -1,5 +1,7 @@import { Injectable, Logger } from '@nestjs/common';+import { isDefined } from 'twenty-shared/utils';+import {MessageImportDriverException,MessageImportDriverExceptionCode,@@ -23,7 +25,13 @@ export class GmailMessagesImportErrorHandler {}if (isGmailApiBatchError(error)) {- throw parseGmailApiBatchError(error, messageExternalId);+ const exception = parseGmailApiBatchError(error, messageExternalId);++ if (!isDefined(exception)) {+ return;+ }++ throw exception;}throw new MessageImportDriverException(diff --git a/packages/twenty-server/src/modules/messaging/message-import-manager/drivers/gmail/utils/__tests__/parse-gmail-messages-import-error.spec.ts b/packages/twenty-server/src/modules/messaging/message-import-manager/drivers/gmail/utils/__tests__/parse-gmail-messages-import-error.spec.tsindex 6f2b99524bb..bd1c44455ed 100644--- a/packages/twenty-server/src/modules/messaging/message-import-manager/drivers/gmail/utils/__tests__/parse-gmail-messages-import-error.spec.ts+++ b/packages/twenty-server/src/modules/messaging/message-import-manager/drivers/gmail/utils/__tests__/parse-gmail-messages-import-error.spec.ts@@ -111,26 +111,14 @@ describe('parseGmailApiBatchError', () => {const error = gmailBatchApiErrorMocks.getError(404);const exception = parseGmailApiBatchError(error, messageExternalId);- expect(exception).toBeInstanceOf(MessageImportDriverException);- expect(exception?.code).toBe(- MessageImportDriverExceptionCode.SYNC_CURSOR_ERROR,- );- expect(exception?.message).toBe(- `${error.errors[0].message} for message with externalId: ${messageExternalId}`,- );+ expect(exception).toBeUndefined();});it('should handle 410 Gone', () => {const error = gmailBatchApiErrorMocks.getError(410);const exception = parseGmailApiBatchError(error, messageExternalId);- expect(exception).toBeInstanceOf(MessageImportDriverException);- expect(exception?.code).toBe(- MessageImportDriverExceptionCode.SYNC_CURSOR_ERROR,- );- expect(exception?.message).toBe(- `${error.errors[0].message} for message with externalId: ${messageExternalId}`,- );+ expect(exception).toBeUndefined();});it('should handle 429 Too Many Requests', () => {diff --git a/packages/twenty-server/src/modules/messaging/message-import-manager/drivers/gmail/utils/parse-gmail-api-batch-error.util.ts b/packages/twenty-server/src/modules/messaging/message-import-manager/drivers/gmail/utils/parse-gmail-api-batch-error.util.tsindex 1314e8e72a0..f2d9755bfdc 100644--- a/packages/twenty-server/src/modules/messaging/message-import-manager/drivers/gmail/utils/parse-gmail-api-batch-error.util.ts+++ b/packages/twenty-server/src/modules/messaging/message-import-manager/drivers/gmail/utils/parse-gmail-api-batch-error.util.ts@@ -43,10 +43,7 @@ export const parseGmailApiBatchError = (case 404:case 410:- return new MessageImportDriverException(- message,- MessageImportDriverExceptionCode.SYNC_CURSOR_ERROR,- );+ return undefined;case 429:return new MessageImportDriverException(