feat(core): Update binary data breaking change (#22100)

This commit is contained in:
Tomi Turtiainen 2025-11-20 17:48:13 +02:00 committed by GitHub
parent ac91020bd3
commit 4c2c1ce9d1
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 49 additions and 24 deletions

View File

@ -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<BinaryDataConfig>();
const binaryDataConfig: BinaryDataConfig = mock<BinaryDataConfig>();
const executionsConfig: ExecutionsConfig = mock<ExecutionsConfig>();
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);
});
});
});

View File

@ -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;