Skip to content

The open alternative to Salesforce, designed for AI.

Throw exception when error code is not defined in messaging import

Charles Bochetd7ce42cff75c
diff --git a/packages/twenty-server/src/modules/messaging/message-import-manager/drivers/gmail/services/messaging-gmail-fetch-messages-by-batches.service.ts b/packages/twenty-server/src/modules/messaging/message-import-manager/drivers/gmail/services/messaging-gmail-fetch-messages-by-batches.service.ts
index cc63ce24889..fbdfa5dab09 100644
--- a/packages/twenty-server/src/modules/messaging/message-import-manager/drivers/gmail/services/messaging-gmail-fetch-messages-by-batches.service.ts
+++ b/packages/twenty-server/src/modules/messaging/message-import-manager/drivers/gmail/services/messaging-gmail-fetch-messages-by-batches.service.ts
@@ -181,11 +181,14 @@ export class MessagingGmailFetchMessagesByBatchesService {
const historyId = message.historyId;
const internalDate = message.internalDate;
- assert(id);
- assert(messageId);
- assert(threadId);
- assert(historyId);
- assert(internalDate);
+ assert(id, 'ID is missing');
+ assert(
+ messageId,
+ 'Message-ID is missing: ' + JSON.stringify(message.payload?.headers),
+ );
+ assert(threadId, 'Thread-ID is missing');
+ assert(historyId, 'History-ID is missing');
+ assert(internalDate, 'Internal date is missing');
const bodyData = this.getBodyData(message);
const text = bodyData ? Buffer.from(bodyData, 'base64').toString() : '';