Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions apps/worker/src/app/workflow/services/workflow.worker.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,13 +47,11 @@ describe('Workflow Worker', () => {
const workflowInMemoryProviderService = moduleRef.get<WorkflowInMemoryProviderService>(
WorkflowInMemoryProviderService
);
const organizationRepository = moduleRef.get<CommunityOrganizationRepository>(CommunityOrganizationRepository);
const featureFlagsService = moduleRef.get<FeatureFlagsService>(FeatureFlagsService);

workflowWorker = new WorkflowWorker(
triggerEventUseCase,
workflowInMemoryProviderService,
organizationRepository,
mockSqsService,
new PinoLogger({}),
featureFlagsService
Expand Down
17 changes: 0 additions & 17 deletions apps/worker/src/app/workflow/services/workflow.worker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ import {
WorkflowInMemoryProviderService,
WorkflowWorkerService,
} from '@novu/application-generic';
import { CommunityOrganizationRepository } from '@novu/dal';
import { FeatureFlagsKeysEnum, ObservabilityBackgroundTransactionEnum } from '@novu/shared';

const nr = require('newrelic');
Expand All @@ -27,7 +26,6 @@ export class WorkflowWorker extends WorkflowWorkerService {
constructor(
private triggerEventUsecase: TriggerEvent,
public workflowInMemoryProviderService: WorkflowInMemoryProviderService,
private organizationRepository: CommunityOrganizationRepository,
sqsService: SqsService,
protected logger: PinoLogger,
private featureFlagsService: FeatureFlagsService
Expand Down Expand Up @@ -92,14 +90,6 @@ export class WorkflowWorker extends WorkflowWorkerService {
return;
}

const organizationExists = await this.organizationExist(data);

if (!organizationExists) {
this.logger.warn(`Organization not found for organizationId ${data.organizationId}. Skipping job.`);

return;
}

return await new Promise((resolve, reject) => {
const _this = this;

Expand Down Expand Up @@ -128,11 +118,4 @@ export class WorkflowWorker extends WorkflowWorkerService {
});
};
Comment on lines 93 to 119
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Missing-org path now silently drops jobs without a dedicated test

Previously, a missing organization caused an explicit early return with a clear log message. Now, if triggerEventUsecase.execute(data) throws because the organization doesn't exist, the job is swallowed by setSqsFailedHandler and permanently dropped (at-most-once). The spec has no test for this failure path — if the use-case doesn't handle a missing org gracefully and throws an unexpected error type, the failure will be invisible beyond the generic setSqsFailedHandler warning. Worth adding a test that stubs triggerEventUsecase.execute to throw and verifies the job is dropped (not retried).

Prompt To Fix With AI
This is a comment left during a code review.
Path: apps/worker/src/app/workflow/services/workflow.worker.ts
Line: 93-119

Comment:
**Missing-org path now silently drops jobs without a dedicated test**

Previously, a missing organization caused an explicit early return with a clear log message. Now, if `triggerEventUsecase.execute(data)` throws because the organization doesn't exist, the job is swallowed by `setSqsFailedHandler` and permanently dropped (at-most-once). The spec has no test for this failure path — if the use-case doesn't handle a missing org gracefully and throws an unexpected error type, the failure will be invisible beyond the generic `setSqsFailedHandler` warning. Worth adding a test that stubs `triggerEventUsecase.execute` to throw and verifies the job is dropped (not retried).

How can I resolve this? If you propose a fix, please make it concise.

Fix in Cursor

}

private async organizationExist(data: IWorkflowDataDto): Promise<boolean> {
const { organizationId } = data;
const organization = await this.organizationRepository.findOne({ _id: organizationId });

return !!organization;
}
}
Loading