handle HTTP 410,404 in GmailMessagesImportErrorHandler (#15969)

Noticed this in prod, we currently return `undefined` instead of
handling it.
This commit is contained in:
neo773
2025-11-21 15:36:21 +05:30
committed by GitHub
parent dc3e30b115
commit f82325b66b
2 changed files with 19 additions and 3 deletions
@@ -138,7 +138,13 @@ describe('parseGmailMessagesImportError', () => {
messageExternalId,
);
expect(exception).toBe(undefined);
expect(exception).toBeInstanceOf(MessageImportDriverException);
expect(exception?.code).toBe(
MessageImportDriverExceptionCode.SYNC_CURSOR_ERROR,
);
expect(exception?.message).toBe(
`${error.error.errors[0].message} for message with externalId: ${messageExternalId}`,
);
});
it('should handle 410 Gone', () => {
@@ -148,7 +154,13 @@ describe('parseGmailMessagesImportError', () => {
messageExternalId,
);
expect(exception).toBe(undefined);
expect(exception).toBeInstanceOf(MessageImportDriverException);
expect(exception?.code).toBe(
MessageImportDriverExceptionCode.SYNC_CURSOR_ERROR,
);
expect(exception?.message).toBe(
`${error.error.errors[0].message} for message with externalId: ${messageExternalId}`,
);
});
it('should handle 429 Too Many Requests', () => {
@@ -53,7 +53,11 @@ export const parseGmailMessagesImportError = (
case 404:
case 410:
return undefined;
return new MessageImportDriverException(
message,
MessageImportDriverExceptionCode.SYNC_CURSOR_ERROR,
{ cause: options?.cause },
);
case 429:
return new MessageImportDriverException(