Compare commits

...
Author SHA1 Message Date
Sonarly Claude CodeandClaude Opus 4.6 e3ec41f904 fix: gracefully handle transient MALFORMED_METADATA errors in WorkflowRunEnqueueCronJob
When workspace metadata cache is empty (e.g. due to transient database
query timeouts), the ORM throws a TwentyORMException with MALFORMED_METADATA
code. Instead of unconditionally reporting these transient errors to Sentry,
log a warning and skip the workspace. The cron runs every 5 minutes, so
the workspace will be retried on the next run.

Fixes https://sentry.io/issues/6648220183/

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-20 03:10:48 +00:00
@@ -12,6 +12,10 @@ import { Processor } from 'src/engine/core-modules/message-queue/decorators/proc
import { MessageQueue } from 'src/engine/core-modules/message-queue/message-queue.constants';
import { MessageQueueService } from 'src/engine/core-modules/message-queue/services/message-queue.service';
import { WorkspaceEntity } from 'src/engine/core-modules/workspace/workspace.entity';
import {
TwentyORMException,
TwentyORMExceptionCode,
} from 'src/engine/twenty-orm/exceptions/twenty-orm.exception';
import { GlobalWorkspaceOrmManager } from 'src/engine/twenty-orm/global-workspace-datasource/global-workspace-orm.manager';
import { buildSystemAuthContext } from 'src/engine/twenty-orm/utils/build-system-auth-context.util';
import { WorkflowRunWorkspaceEntity } from 'src/modules/workflow/common/standard-objects/workflow-run.workspace-entity';
@@ -68,11 +72,20 @@ export class WorkflowRunEnqueueCronJob {
enqueuedCount++;
}
} catch (error) {
this.exceptionHandlerService.captureExceptions([error], {
workspace: {
id: workspace.id,
},
});
if (
error instanceof TwentyORMException &&
error.code === TwentyORMExceptionCode.MALFORMED_METADATA
) {
this.logger.warn(
`Skipping workspace ${workspace.id}: workspace metadata not available yet`,
);
} else {
this.exceptionHandlerService.captureExceptions([error], {
workspace: {
id: workspace.id,
},
});
}
}
}