n8n - ✅(Solved) Fix bug(rules-engine): Path mismatch causes test failures and baseline invalidation on Windows [1 pull requests, 1 comments, 2 participants]

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…
GitHub stats
n8n-io/n8n#29413Fetched 2026-04-29 06:35:07
View on GitHub
Comments
1
Participants
2
Timeline
5
Reactions
0
Timeline (top)
commented ×1cross-referenced ×1labeled ×1mentioned ×1

Root Cause

When running natively on Windows, path.relative() returns backslashes (), which triggers two specific failures:

  1. Test Failures: Hardcoded assertions in reporter.test.ts and baseline.test.ts fail when comparing Windows-native paths against hardcoded POSIX strings.
  2. Baseline Invalidation: The isInBaseline check fails to find existing violations because it searches for keys with backslashes in a JSON file that was committed with forward slashes, leading to false-positive report errors on Windows machines.

Fix Action

Fixed

PR fix notes

PR #29415: fix(rules-engine): normalize paths for cross-platform compatibility (…

Description (problem / solution / changelog)

Summary

This PR fixes a cross-platform bug in the @n8n/rules-engine package where Windows-specific backslashes (\) were causing test failures and invalidating the violations baseline.

The Fix:

  • Introduced a normalizePath helper in baseline.ts to replace all backslashes with POSIX forward slashes (/).
  • Wrapped path.relative() calls in hashViolation, generateBaseline, and isInBaseline with the normalizer to ensure internal records remain OS-agnostic.
  • Updated the test suite (reporter.test.ts and baseline.test.ts) to ensure assertions match the normalized POSIX output.

How to Test:

  1. On a native Windows environment, navigate to the monorepo root.
  2. Run: pnpm --filter @n8n/rules-engine test
  3. Verify that all 22 tests pass cleanly (resolving the previous AssertionError path mismatches).

Related Linear tickets, Github issues, and Community forum posts

fixes #29413 <img width="971" height="412" alt="Screenshot 2026-04-28 203001" src="https://github.com/user-attachments/assets/85eba947-40c7-4b69-b5da-6d4cec85acae" />

Review / Merge checklist

  • I have seen this code, I have run this code, and I take responsibility for this code.
  • PR title and summary are descriptive. (conventions) - [ ] Docs updated or follow-up ticket created.
  • Tests included. - [ ] PR Labeled with Backport to Beta, Backport to Stable, or Backport to v1 (if the PR is an urgent fix that needs to be backported)

Changed files

  • packages/testing/rules-engine/src/baseline.ts (modified, +7/-3)
  • packages/testing/rules-engine/src/reporter.test.ts (modified, +2/-2)
RAW_BUFFERClick to expand / collapse

Bug Description

The @n8n/rules-engine package assumes POSIX-style forward slashes (/) for file paths in both its test assertions and the generated baseline.json files.

When running natively on Windows, path.relative() returns backslashes (), which triggers two specific failures:

  1. Test Failures: Hardcoded assertions in reporter.test.ts and baseline.test.ts fail when comparing Windows-native paths against hardcoded POSIX strings.
  2. Baseline Invalidation: The isInBaseline check fails to find existing violations because it searches for keys with backslashes in a JSON file that was committed with forward slashes, leading to false-positive report errors on Windows machines.

To Reproduce

<!-- Failed to upload "Screenshot 2026-04-28 201222.png" -->

Expected behavior

The rules engine and its test suite should be OS-agnostic. File paths within the baseline and reports should be normalized to POSIX format (forward slashes) to ensure consistency and interoperability between developers on Windows, macOS, and Linux.

Debug Info

  • OS: Windows 10/11 (MINGW64 / Git Bash)
  • Environment: Native Windows development
  • Package: @n8n/rules-engine
  • Test Runner: Vitest

Operating System

windows 11

n8n Version

2.18.04

Node.js Version

22.16

Database

SQLite (default)

Execution mode

main (default)

Hosting

self hosted

extent analysis

TL;DR

Normalizing file paths to POSIX format (forward slashes) in the @n8n/rules-engine package can resolve the issue.

Guidance

  • Verify that the path.relative() function is being used consistently across the codebase and consider using a path normalization library to ensure OS-agnostic paths.
  • Update the hardcoded assertions in reporter.test.ts and baseline.test.ts to use normalized paths or regex patterns that account for both forward and backslashes.
  • Investigate using a library like path-posix to normalize file paths in the isInBaseline check to ensure consistency between Windows and non-Windows environments.
  • Consider adding OS-agnostic testing to ensure the rules engine works correctly across different operating systems.

Example

const path = require('path');
const posixPath = require('path-posix');

// Normalize path to POSIX format
const normalizedPath = posixPath.normalize(path.relative('base', 'path'));

Notes

The provided solution assumes that normalizing file paths to POSIX format will resolve the issue, but further testing may be required to ensure the rules engine works correctly across different operating systems.

Recommendation

Apply workaround: Normalize file paths to POSIX format to ensure consistency and interoperability between developers on Windows, macOS, and Linux. This approach allows for a quick fix without requiring significant changes to the underlying codebase.

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

FAQ

Expected behavior

The rules engine and its test suite should be OS-agnostic. File paths within the baseline and reports should be normalized to POSIX format (forward slashes) to ensure consistency and interoperability between developers on Windows, macOS, and Linux.

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING