Skip to content

The open alternative to Salesforce, designed for AI.

catching better internal errors from google (#12663)

Guillim0ae43f518de5
diff --git a/packages/twenty-server/src/modules/calendar/calendar-event-import-manager/drivers/google-calendar/services/google-calendar-get-events.service.ts b/packages/twenty-server/src/modules/calendar/calendar-event-import-manager/drivers/google-calendar/services/google-calendar-get-events.service.ts
index 53383ee25a6..c3600548f42 100644
--- a/packages/twenty-server/src/modules/calendar/calendar-event-import-manager/drivers/google-calendar/services/google-calendar-get-events.service.ts
+++ b/packages/twenty-server/src/modules/calendar/calendar-event-import-manager/drivers/google-calendar/services/google-calendar-get-events.service.ts
@@ -83,6 +83,7 @@ export class GoogleCalendarGetEventsService {
private handleError(error: GaxiosError) {
this.logger.error(
`Error in ${GoogleCalendarGetEventsService.name} - getCalendarEvents`,
+ error.code,
error,
);
if (
diff --git a/packages/twenty-server/src/modules/calendar/calendar-event-import-manager/drivers/google-calendar/utils/parse-google-calendar-error.util.ts b/packages/twenty-server/src/modules/calendar/calendar-event-import-manager/drivers/google-calendar/utils/parse-google-calendar-error.util.ts
index f7ddd8e2faa..224c87910df 100644
--- a/packages/twenty-server/src/modules/calendar/calendar-event-import-manager/drivers/google-calendar/utils/parse-google-calendar-error.util.ts
+++ b/packages/twenty-server/src/modules/calendar/calendar-event-import-manager/drivers/google-calendar/utils/parse-google-calendar-error.util.ts
@@ -64,7 +64,7 @@ export const parseGoogleCalendarError = (error: {
CalendarEventImportDriverExceptionCode.INSUFFICIENT_PERMISSIONS,
);
case 500:
- if (reason === 'backendError') {
+ if (reason === 'backendError' || reason === 'internal_failure') {
return new CalendarEventImportDriverException(
message,
CalendarEventImportDriverExceptionCode.TEMPORARY_ERROR,
diff --git a/packages/twenty-server/src/modules/calendar/calendar-event-import-manager/services/calendar-event-import-exception-handler.service.ts b/packages/twenty-server/src/modules/calendar/calendar-event-import-manager/services/calendar-event-import-exception-handler.service.ts
index 3234d425522..d318ec991a1 100644
--- a/packages/twenty-server/src/modules/calendar/calendar-event-import-manager/services/calendar-event-import-exception-handler.service.ts
+++ b/packages/twenty-server/src/modules/calendar/calendar-event-import-manager/services/calendar-event-import-exception-handler.service.ts
@@ -1,4 +1,4 @@
-import { Injectable } from '@nestjs/common';
+import { Injectable, Logger } from '@nestjs/common';
import { ExceptionHandlerService } from 'src/engine/core-modules/exception-handler/exception-handler.service';
import { TwentyORMManager } from 'src/engine/twenty-orm/twenty-orm.manager';
@@ -21,6 +21,9 @@ export enum CalendarEventImportSyncStep {
@Injectable()
export class CalendarEventImportErrorHandlerService {
+ private readonly logger = new Logger(
+ CalendarEventImportErrorHandlerService.name,
+ );
constructor(
private readonly twentyORMManager: TwentyORMManager,
private readonly calendarChannelSyncStatusService: CalendarChannelSyncStatusService,
@@ -167,11 +170,13 @@ export class CalendarEventImportErrorHandlerService {
CalendarEventImportExceptionCode.UNKNOWN,
);
+ this.logger.log(exception);
this.exceptionHandlerService.captureExceptions(
[calendarEventImportException],
{
additionalData: {
calendarChannelId: calendarChannel.id,
+ exception,
},
workspace: {
id: workspaceId,
diff --git a/packages/twenty-server/src/modules/connected-account/refresh-tokens-manager/services/connected-account-refresh-tokens.service.ts b/packages/twenty-server/src/modules/connected-account/refresh-tokens-manager/services/connected-account-refresh-tokens.service.ts
index 8af298533e8..3e50623973d 100644
--- a/packages/twenty-server/src/modules/connected-account/refresh-tokens-manager/services/connected-account-refresh-tokens.service.ts
+++ b/packages/twenty-server/src/modules/connected-account/refresh-tokens-manager/services/connected-account-refresh-tokens.service.ts
@@ -1,4 +1,4 @@
-import { Injectable } from '@nestjs/common';
+import { Injectable, Logger } from '@nestjs/common';
import { ConnectedAccountProvider } from 'twenty-shared/types';
import { assertUnreachable } from 'twenty-shared/utils';
@@ -22,6 +22,10 @@ export type ConnectedAccountTokens = GoogleTokens | MicrosoftTokens;
@Injectable()
export class ConnectedAccountRefreshTokensService {
+ private readonly logger = new Logger(
+ ConnectedAccountRefreshTokensService.name,
+ );
+
constructor(
private readonly googleAPIRefreshAccessTokenService: GoogleAPIRefreshAccessTokenService,
private readonly microsoftAPIRefreshAccessTokenService: MicrosoftAPIRefreshAccessTokenService,
@@ -88,8 +92,9 @@ export class ConnectedAccountRefreshTokensService {
);
}
} catch (error) {
+ this.logger.log(error);
throw new ConnectedAccountRefreshAccessTokenException(
- `Error refreshing tokens for connected account ${connectedAccount.id} in workspace ${workspaceId}: ${error.message} ${error?.response?.data?.error_description}`,
+ `Error refreshing tokens for connected account ${connectedAccount.id.slice(0, 7)} in workspace ${workspaceId.slice(0, 7)}: ${error.message} ${error?.response?.data?.error_description}`,
ConnectedAccountRefreshAccessTokenExceptionCode.REFRESH_ACCESS_TOKEN_FAILED,
);
}