Skip to content

Commit

Permalink
fix(core): Throw on adding execution without execution data (#9903)
Browse files Browse the repository at this point in the history
  • Loading branch information
ivov committed Jul 3, 2024
1 parent 82703d6 commit ada1adb
Showing 1 changed file with 18 additions and 2 deletions.
20 changes: 18 additions & 2 deletions packages/cli/src/databases/repositories/execution.repository.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,8 @@ import { ExecutionDataRepository } from './executionData.repository';
import { Logger } from '@/Logger';
import type { ExecutionSummaries } from '@/executions/execution.types';
import { PostgresLiveRowsRetrievalError } from '@/errors/postgres-live-rows-retrieval.error';
import { separate } from '@/utils';
import { ErrorReporterProxy as ErrorReporter } from 'n8n-workflow';

export interface IGetExecutionsQueryFilter {
id?: FindOperator<string> | string;
Expand Down Expand Up @@ -155,7 +157,9 @@ export class ExecutionRepository extends Repository<ExecutionEntity> {
const executions = await this.find(queryParams);

if (options?.includeData && options?.unflattenData) {
return executions.map((execution) => {
const [valid, invalid] = separate(executions, (e) => e.executionData !== null);
this.reportInvalidExecutions(invalid);
return valid.map((execution) => {
const { executionData, metadata, ...rest } = execution;
return {
...rest,
Expand All @@ -165,7 +169,9 @@ export class ExecutionRepository extends Repository<ExecutionEntity> {
} as IExecutionResponse;
});
} else if (options?.includeData) {
return executions.map((execution) => {
const [valid, invalid] = separate(executions, (e) => e.executionData !== null);
this.reportInvalidExecutions(invalid);
return valid.map((execution) => {
const { executionData, metadata, ...rest } = execution;
return {
...rest,
Expand All @@ -182,6 +188,16 @@ export class ExecutionRepository extends Repository<ExecutionEntity> {
});
}

reportInvalidExecutions(executions: ExecutionEntity[]) {
if (executions.length === 0) return;

ErrorReporter.error(
new ApplicationError('Found executions without executionData', {
extra: { executionIds: executions.map(({ id }) => id) },
}),
);
}

async findSingleExecution(
id: string,
options?: {
Expand Down

0 comments on commit ada1adb

Please sign in to comment.