diff --git a/packages/cli/src/modules/breaking-changes/rules/v2/__tests__/binary-data-storage.rule.test.ts b/packages/cli/src/modules/breaking-changes/rules/v2/__tests__/binary-data-storage.rule.test.ts index 6d76fe25412..dd8d55f394e 100644 --- a/packages/cli/src/modules/breaking-changes/rules/v2/__tests__/binary-data-storage.rule.test.ts +++ b/packages/cli/src/modules/breaking-changes/rules/v2/__tests__/binary-data-storage.rule.test.ts @@ -1,3 +1,4 @@ +import type { ExecutionsConfig } from '@n8n/config'; import { mock } from 'jest-mock-extended'; import type { BinaryDataConfig } from 'n8n-core'; @@ -5,23 +6,26 @@ import { BinaryDataStorageRule } from '../binary-data-storage.rule'; describe('BinaryDataStorageRule', () => { let rule: BinaryDataStorageRule; - const config: BinaryDataConfig = mock(); + const binaryDataConfig: BinaryDataConfig = mock(); + const executionsConfig: ExecutionsConfig = mock(); beforeEach(() => { - rule = new BinaryDataStorageRule(config); + rule = new BinaryDataStorageRule(binaryDataConfig, executionsConfig); }); describe('detect()', () => { it('should not be affected if mode is not default', async () => { - config.mode = 'filesystem'; + binaryDataConfig.mode = 'filesystem'; + executionsConfig.mode = 'regular'; const result = await rule.detect(); expect(result.isAffected).toBe(false); expect(result.instanceIssues).toHaveLength(0); }); - it('should be affected if mode is default', async () => { - config.mode = 'default'; + it('should be affected if mode is default and execution mode is regular', async () => { + binaryDataConfig.mode = 'default'; + executionsConfig.mode = 'regular'; const result = await rule.detect(); expect(result.isAffected).toBe(true); @@ -30,5 +34,16 @@ describe('BinaryDataStorageRule', () => { expect(result.recommendations).toHaveLength(3); expect(result.recommendations[0].action).toBe('Ensure adequate disk space'); }); + + it('should be affected if mode is default and execution mode is queue', async () => { + binaryDataConfig.mode = 'default'; + executionsConfig.mode = 'queue'; + const result = await rule.detect(); + + expect(result.isAffected).toBe(true); + expect(result.instanceIssues).toHaveLength(1); + expect(result.instanceIssues[0].title).toBe('Binary data storage mode changed'); + expect(result.recommendations).toHaveLength(0); + }); }); }); diff --git a/packages/cli/src/modules/breaking-changes/rules/v2/binary-data-storage.rule.ts b/packages/cli/src/modules/breaking-changes/rules/v2/binary-data-storage.rule.ts index 6a302411e71..0b67cbfe2a4 100644 --- a/packages/cli/src/modules/breaking-changes/rules/v2/binary-data-storage.rule.ts +++ b/packages/cli/src/modules/breaking-changes/rules/v2/binary-data-storage.rule.ts @@ -1,3 +1,4 @@ +import { ExecutionsConfig } from '@n8n/config'; import { Service } from '@n8n/di'; import { BinaryDataConfig } from 'n8n-core'; @@ -10,16 +11,19 @@ import { BreakingChangeCategory } from '../../types'; @Service() export class BinaryDataStorageRule implements IBreakingChangeInstanceRule { - constructor(private readonly config: BinaryDataConfig) {} + constructor( + private readonly config: BinaryDataConfig, + private readonly executionsConfig: ExecutionsConfig, + ) {} id: string = 'binary-data-storage-v2'; getMetadata(): BreakingChangeRuleMetadata { return { version: 'v2', - title: 'Disable binary data in-memory mode by default', + title: 'Binary data in-memory mode is removed', description: - 'Binary files are now stored on disk by default instead of in memory, removing the 512MB file size limit', + 'Binary files are now stored on disk (default in regular mode) or in database (default in queue mode) instead of in memory', category: BreakingChangeCategory.infrastructure, severity: 'low', documentationUrl: @@ -36,30 +40,36 @@ export class BinaryDataStorageRule implements IBreakingChangeInstanceRule { }; } + const isRegularMode = this.executionsConfig.mode === 'regular'; + const result: InstanceDetectionReport = { isAffected: true, instanceIssues: [ { title: 'Binary data storage mode changed', - description: `Binary files are now stored in ${this.config.localStoragePath} directory by default instead of in memory. This removes the previous 512MB file size limit but increases disk usage.`, + description: isRegularMode + ? `Binary files are now stored in ${this.config.localStoragePath} directory by default (for regular mode) instead of in memory.` + : 'Binary files are now stored in the database by default (for queue mode) instead of in memory.', level: 'info', }, ], - recommendations: [ - { - action: 'Ensure adequate disk space', - description: `Verify sufficient disk space is available for binary file storage in the ${this.config.localStoragePath} directory`, - }, - { - action: 'Configure persistent storage', - description: - 'If using containers, ensure the binary data directory is mounted on a persistent volume', - }, - { - action: 'Include in backups', - description: 'Add the binary data folder to your backup procedures', - }, - ], + recommendations: isRegularMode + ? [ + { + action: 'Ensure adequate disk space', + description: `Verify sufficient disk space is available for binary file storage in the ${this.config.localStoragePath} directory`, + }, + { + action: 'Configure persistent storage', + description: + 'If using containers, ensure the binary data directory is mounted on a persistent volume', + }, + { + action: 'Include in backups', + description: 'Add the binary data folder to your backup procedures', + }, + ] + : [], }; return result;