Skip to content

Conversation

@CharlieKolb
Copy link
Contributor

@CharlieKolb CharlieKolb commented Jan 8, 2026

Summary

A few changes here:

  • Actually include rule to never delete consecutive versions by different users
  • Simplify groupWorkflows severely - this proves unnecessary and introduced two bugs this PR fixes
  • Move rules definition from workflow-history.repo to the service in preparation of a second compaction cycle after a week
  • Remove more unused code

Related Linear tickets, Github issues, and Community forum posts

https://linear.app/n8n/issue/ADO-4601

Review / Merge checklist

  • PR title and summary are descriptive. (conventions)
  • Docs updated or follow-up ticket created.
  • Tests included.
  • PR Labeled with release/backport (if the PR is an urgent fix that needs to be backported)

@CharlieKolb CharlieKolb marked this pull request as ready for review January 8, 2026 14:12
@codecov
Copy link

codecov bot commented Jan 8, 2026

Codecov Report

❌ Patch coverage is 76.47059% with 16 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
...db/src/repositories/workflow-history.repository.ts 12.50% 7 Missing ⚠️
packages/workflow/src/workflow-diff.ts 85.36% 5 Missing and 1 partial ⚠️
...ces/pruning/workflow-history-compaction.service.ts 84.21% 3 Missing ⚠️

📢 Thoughts on this report? Let us know!

Copy link
Contributor

@cubic-dev-ai cubic-dev-ai bot left a comment

Choose a reason for hiding this comment

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

2 issues found across 6 files

Prompt for AI agents (all issues)

Check if these issues are valid — if so, understand the root cause of each and fix them.


<file name="packages/@n8n/db/src/repositories/workflow-history.repository.ts">

<violation number="1" location="packages/@n8n/db/src/repositories/workflow-history.repository.ts:101">
P1: `SKIP_RULES.skipDifferentUsers` expects a `user` property but `WorkflowHistory` entity has `authors` instead. This will always compare `undefined !== undefined` (returns `false`), so consecutive versions by different users will NOT be protected from deletion as intended.</violation>
</file>

<file name="packages/workflow/src/workflow-diff.ts">

<violation number="1" location="packages/workflow/src/workflow-diff.ts:234">
P2: Incomplete error message - the text cuts off after "no ". This should describe what's missing (e.g., "no right diff" or "no right element") for better debugging.</violation>
</file>

Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review.

if (shouldMerge) {
const right = diffs.splice(i, 1)[0];
if (!right) throw new Error('invariant broken');
if (!right) throw new Error('invariant broken - no ');
Copy link
Contributor

@cubic-dev-ai cubic-dev-ai bot Jan 8, 2026

Choose a reason for hiding this comment

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

P2: Incomplete error message - the text cuts off after "no ". This should describe what's missing (e.g., "no right diff" or "no right element") for better debugging.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At packages/workflow/src/workflow-diff.ts, line 234:

<comment>Incomplete error message - the text cuts off after "no ". This should describe what's missing (e.g., "no right diff" or "no right element") for better debugging.</comment>

<file context>
@@ -277,13 +225,13 @@ export function groupWorkflows<W extends WorkflowDiffBase = WorkflowDiffBase>(
 				if (shouldMerge) {
 					const right = diffs.splice(i, 1)[0];
-					if (!right) throw new Error('invariant broken');
+					if (!right) throw new Error('invariant broken - no ');
 
 					// merge diffs
</file context>
Suggested change
if (!right) throw new Error('invariant broken - no ');
if (!right) throw new Error('invariant broken - no right diff');

✅ Addressed in 8ce7ce6

@blacksmith-sh

This comment has been minimized.

@n8n-assistant n8n-assistant bot added core Enhancement outside /nodes-base and /editor-ui n8n team Authored by the n8n team labels Jan 8, 2026
@currents-bot
Copy link

currents-bot bot commented Jan 8, 2026

E2E Tests: n8n tests passed after 10m 15s

🟢 609 · 🔴 0 · ⚪️ 38 · 🟣 2

View Run Details

Run Details

  • Project: n8n

  • Groups: 2

  • Framework: Playwright

  • Run Status: Passed

  • Commit: 3cc9327

  • Spec files: 142

  • Overall tests: 647

  • Duration: 10m 15s

  • Parallelization: 16

Groups

GroupId Results Spec Files Progress
multi-main:e2e:isolated 🟢 57 · 🔴 0 · ⚪️ 0 9 / 9
multi-main:e2e 🟢 552 · 🔴 0 · ⚪️ 38 · 🟣 2 133 / 133


This message was posted automatically by currents.dev | Integration Settings

Copy link
Contributor

@cubic-dev-ai cubic-dev-ai bot left a comment

Choose a reason for hiding this comment

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

3 issues found across 3 files (changes from recent commits).

Prompt for AI agents (all issues)

Check if these issues are valid — if so, understand the root cause of each and fix them.


<file name="packages/cli/test/integration/database/repositories/workflow-history.repository.test.ts">

<violation number="1" location="packages/cli/test/integration/database/repositories/workflow-history.repository.test.ts:116">
P0: `it.only` should not be committed. This will cause all other tests in the file to be skipped, breaking CI test coverage.</violation>

<violation number="2" location="packages/cli/test/integration/database/repositories/workflow-history.repository.test.ts:173">
P1: Commented-out assertions suggest incomplete test or debugging code. The test title states it should 'never prune previously active or named versions', but assertions for id2 (named version) and id4 (activated version) are commented out, which contradicts the test's stated purpose.</violation>
</file>

<file name="packages/workflow/src/workflow-diff.ts">

<violation number="1" location="packages/workflow/src/workflow-diff.ts:17">
P1: Rule violated: **Tests**

Tests for `skipDifferentUsers` use the old `user` property, but the implementation now uses `authors`. The test helper creates workflows with `{ user }` but the type expects `{ authors }`. These tests need to be updated to match the implementation change.</violation>
</file>

Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review.

});

it('should never prune previously active or named versions', async () => {
it.only('should never prune previously active or named versions', async () => {
Copy link
Contributor

@cubic-dev-ai cubic-dev-ai bot Jan 8, 2026

Choose a reason for hiding this comment

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

P0: it.only should not be committed. This will cause all other tests in the file to be skipped, breaking CI test coverage.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At packages/cli/test/integration/database/repositories/workflow-history.repository.test.ts, line 116:

<comment>`it.only` should not be committed. This will cause all other tests in the file to be skipped, breaking CI test coverage.</comment>

<file context>
@@ -113,7 +113,7 @@ describe('WorkflowHistoryRepository', () => {
 		});
 
-		it('should never prune previously active or named versions', async () => {
+		it.only('should never prune previously active or named versions', async () => {
 			// ARRANGE
 			const id1 = uuid();
</file context>
Suggested change
it.only('should never prune previously active or named versions', async () => {
it('should never prune previously active or named versions', async () => {

✅ Addressed in 8ce7ce6

// ASSERT
expect(deleted).toBe(1);
expect(seen).toBe(5);
// expect(deleted).toBe(1);
Copy link
Contributor

@cubic-dev-ai cubic-dev-ai bot Jan 8, 2026

Choose a reason for hiding this comment

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

P1: Commented-out assertions suggest incomplete test or debugging code. The test title states it should 'never prune previously active or named versions', but assertions for id2 (named version) and id4 (activated version) are commented out, which contradicts the test's stated purpose.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At packages/cli/test/integration/database/repositories/workflow-history.repository.test.ts, line 173:

<comment>Commented-out assertions suggest incomplete test or debugging code. The test title states it should 'never prune previously active or named versions', but assertions for id2 (named version) and id4 (activated version) are commented out, which contradicts the test's stated purpose.</comment>

<file context>
@@ -169,15 +169,16 @@ describe('WorkflowHistoryRepository', () => {
 			// ASSERT
-			expect(deleted).toBe(1);
 			expect(seen).toBe(5);
+			// expect(deleted).toBe(1);
 
 			const history = await repository.find();
</file context>

✅ Addressed in 8ce7ce6

connections: IConnections;
createdAt: Date;
user?: unknown;
authors?: string;
Copy link
Contributor

@cubic-dev-ai cubic-dev-ai bot Jan 8, 2026

Choose a reason for hiding this comment

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

P1: Rule violated: Tests

Tests for skipDifferentUsers use the old user property, but the implementation now uses authors. The test helper creates workflows with { user } but the type expects { authors }. These tests need to be updated to match the implementation change.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At packages/workflow/src/workflow-diff.ts, line 17:

<comment>Tests for `skipDifferentUsers` use the old `user` property, but the implementation now uses `authors`. The test helper creates workflows with `{ user }` but the type expects `{ authors }`. These tests need to be updated to match the implementation change.</comment>

<file context>
@@ -14,7 +14,7 @@ export type DiffableWorkflow<N extends DiffableNode = DiffableNode> = {
 	connections: IConnections;
 	createdAt: Date;
-	user?: unknown;
+	authors?: string;
 };
 
</file context>
Fix with Cubic

Copy link
Contributor

@cubic-dev-ai cubic-dev-ai bot left a comment

Choose a reason for hiding this comment

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

1 issue found across 4 files (changes from recent commits).

Prompt for AI agents (all issues)

Check if these issues are valid — if so, understand the root cause of each and fix them.


<file name="packages/cli/test/integration/database/repositories/workflow-history.repository.test.ts">

<violation number="1" location="packages/cli/test/integration/database/repositories/workflow-history.repository.test.ts:173">
P1: Test assertion contradicts test purpose. The test is named "should never prune previously active or named versions" but expects `id4` (which has publish history with `event: 'activated'`) to be pruned. Either the test name should be updated, or `id4` should be included in the expected result with `deleted` being 1 instead of 2.</violation>
</file>

Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review.

Copy link
Contributor

@RicardoE105 RicardoE105 left a comment

Choose a reason for hiding this comment

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

🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

core Enhancement outside /nodes-base and /editor-ui n8n team Authored by the n8n team

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants