mirror of
https://github.com/czlonkowski/n8n-mcp.git
synced 2026-03-23 19:03:07 +00:00
Compare commits
2 Commits
v2.20.8
...
enhance/va
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
ee4e20a1ee | ||
|
|
0c050bda6d |
452
CHANGELOG.md
452
CHANGELOG.md
@@ -7,458 +7,6 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|||||||
|
|
||||||
## [Unreleased]
|
## [Unreleased]
|
||||||
|
|
||||||
## [2.20.8] - 2025-10-22
|
|
||||||
|
|
||||||
### 🐛 Bug Fixes
|
|
||||||
|
|
||||||
**Sticky Notes Validation - Disconnected Node False Positives**
|
|
||||||
|
|
||||||
Fixed critical bug where sticky notes (UI-only annotation nodes) were incorrectly triggering "disconnected node" validation errors when updating workflows via MCP tools.
|
|
||||||
|
|
||||||
#### Problem
|
|
||||||
- Workflows with sticky notes failed validation with "Node is disconnected" errors
|
|
||||||
- `n8n_update_partial_workflow` and `n8n_update_full_workflow` tools blocked legitimate updates
|
|
||||||
- Example error: "Validation Error: Node '📝 Webhook Trigger' is disconnected"
|
|
||||||
- Sticky notes are UI-only annotations and should never trigger connection validation
|
|
||||||
|
|
||||||
#### Root Cause Analysis
|
|
||||||
|
|
||||||
**Inconsistent Validation Logic:**
|
|
||||||
- `src/services/workflow-validator.ts` correctly excluded sticky notes using private `isStickyNote()` method
|
|
||||||
- `src/services/n8n-validation.ts` lacked sticky note exclusion logic entirely
|
|
||||||
- Code duplication led to divergent behavior between validators
|
|
||||||
|
|
||||||
**Missing Checks in n8n-validation.ts:**
|
|
||||||
```typescript
|
|
||||||
// BEFORE (Broken) - lines 246-257:
|
|
||||||
const webhookTypes = new Set([
|
|
||||||
'n8n-nodes-base.webhook',
|
|
||||||
'n8n-nodes-base.webhookTrigger',
|
|
||||||
'n8n-nodes-base.manualTrigger'
|
|
||||||
]);
|
|
||||||
// Only checked for webhooks, missed sticky notes entirely
|
|
||||||
const disconnectedNodes = workflow.nodes.filter(node => {
|
|
||||||
const isConnected = connectedNodes.has(node.name);
|
|
||||||
const isTrigger = webhookTypes.has(node.type);
|
|
||||||
// ...
|
|
||||||
});
|
|
||||||
```
|
|
||||||
|
|
||||||
#### Fixed
|
|
||||||
|
|
||||||
**1. Created Shared Utility Module** (`src/utils/node-classification.ts`)
|
|
||||||
- Centralized node classification logic to ensure consistency
|
|
||||||
- Four core functions:
|
|
||||||
- `isStickyNote()`: Identifies all sticky note type variations
|
|
||||||
- `isTriggerNode()`: Identifies trigger nodes (webhook, manual, cron, schedule)
|
|
||||||
- `isNonExecutableNode()`: Identifies UI-only nodes
|
|
||||||
- `requiresIncomingConnection()`: Determines if node needs incoming connections
|
|
||||||
|
|
||||||
**2. Updated n8n-validation.ts** (lines 198-259)
|
|
||||||
- Added imports: `import { isNonExecutableNode, isTriggerNode } from '../utils/node-classification'`
|
|
||||||
- Fixed disconnected nodes check to skip non-executable nodes:
|
|
||||||
```typescript
|
|
||||||
// AFTER (Fixed):
|
|
||||||
const disconnectedNodes = workflow.nodes.filter(node => {
|
|
||||||
// Skip non-executable nodes (sticky notes, etc.) - they're UI-only annotations
|
|
||||||
if (isNonExecutableNode(node.type)) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
const isConnected = connectedNodes.has(node.name);
|
|
||||||
const isTrigger = isTriggerNode(node.type);
|
|
||||||
// ...
|
|
||||||
});
|
|
||||||
```
|
|
||||||
- Added validation for workflows with only sticky notes
|
|
||||||
- Fixed multi-node connection check to exclude sticky notes when counting executable nodes
|
|
||||||
|
|
||||||
**3. Updated workflow-validator.ts** (8 locations)
|
|
||||||
- Removed private `isStickyNote()` method
|
|
||||||
- Replaced all calls with `isNonExecutableNode()` from shared utilities
|
|
||||||
- Eliminates code duplication
|
|
||||||
|
|
||||||
#### Testing
|
|
||||||
|
|
||||||
**New Test Files:**
|
|
||||||
- `tests/unit/utils/node-classification.test.ts`: 44 tests, 100% coverage
|
|
||||||
- Tests all classification functions
|
|
||||||
- Tests all sticky note type variations
|
|
||||||
- Tests trigger node identification
|
|
||||||
- Integration scenarios
|
|
||||||
|
|
||||||
- `tests/unit/services/n8n-validation-sticky-notes.test.ts`: 10 comprehensive tests
|
|
||||||
- Workflows with sticky notes and connected functional nodes
|
|
||||||
- Multiple sticky notes (10+ notes)
|
|
||||||
- All sticky note type variations
|
|
||||||
- Complex real-world scenarios (simulates POST /auth/login workflow)
|
|
||||||
- Detection of truly disconnected functional nodes
|
|
||||||
- Regression tests matching n8n UI behavior
|
|
||||||
|
|
||||||
**Updated Test Files:**
|
|
||||||
- `tests/unit/validation-fixes.test.ts`: Updated terminology to reflect shared utilities
|
|
||||||
|
|
||||||
**Test Results:**
|
|
||||||
- All 54 new tests passing
|
|
||||||
- 100% coverage on node-classification utilities
|
|
||||||
- Zero regressions in existing test suite
|
|
||||||
|
|
||||||
#### Impact
|
|
||||||
|
|
||||||
**Workflow Updates:**
|
|
||||||
- ✅ Sticky notes no longer block workflow updates
|
|
||||||
- ✅ `n8n_update_partial_workflow` works correctly with annotated workflows
|
|
||||||
- ✅ `n8n_update_full_workflow` accepts workflows with documentation notes
|
|
||||||
- ✅ Matches n8n UI behavior exactly
|
|
||||||
|
|
||||||
**Code Quality:**
|
|
||||||
- ✅ Eliminated code duplication between validators
|
|
||||||
- ✅ Centralized node classification logic
|
|
||||||
- ✅ Future node types can be added in one place
|
|
||||||
- ✅ Consistent behavior across all validation paths
|
|
||||||
|
|
||||||
**Node Type Support:**
|
|
||||||
- ✅ Handles all sticky note variations: `n8n-nodes-base.stickyNote`, `nodes-base.stickyNote`, `@n8n/n8n-nodes-base.stickyNote`
|
|
||||||
- ✅ Proper trigger node detection: webhook, webhookTrigger, manualTrigger, cronTrigger, scheduleTrigger
|
|
||||||
- ✅ Correct connection requirements for all node types
|
|
||||||
|
|
||||||
**Backward Compatibility:**
|
|
||||||
- ✅ No breaking changes
|
|
||||||
- ✅ All existing validations continue to work
|
|
||||||
- ✅ API remains unchanged
|
|
||||||
|
|
||||||
Concieved by Romuald Członkowski - [www.aiadvisors.pl/en](https://www.aiadvisors.pl/en)
|
|
||||||
|
|
||||||
## [2.20.7] - 2025-10-22
|
|
||||||
|
|
||||||
### 🔄 Dependencies
|
|
||||||
|
|
||||||
**Updated n8n to v1.116.2**
|
|
||||||
|
|
||||||
Updated all n8n dependencies to the latest compatible versions:
|
|
||||||
- `n8n`: 1.115.2 → 1.116.2
|
|
||||||
- `n8n-core`: 1.114.0 → 1.115.1
|
|
||||||
- `n8n-workflow`: 1.112.0 → 1.113.0
|
|
||||||
- `@n8n/n8n-nodes-langchain`: 1.114.1 → 1.115.1
|
|
||||||
|
|
||||||
**Database Rebuild:**
|
|
||||||
- Rebuilt node database with 542 nodes from updated n8n packages
|
|
||||||
- All 542 nodes loaded successfully from both n8n-nodes-base (439 nodes) and @n8n/n8n-nodes-langchain (103 nodes)
|
|
||||||
- Documentation mapping completed for all nodes
|
|
||||||
|
|
||||||
**Testing:**
|
|
||||||
- Changes validated in CI/CD pipeline with full test suite (705 tests)
|
|
||||||
- Critical nodes validated: httpRequest, code, slack, agent
|
|
||||||
|
|
||||||
### 🐛 Bug Fixes
|
|
||||||
|
|
||||||
**FTS5 Search Ranking - Exact Match Prioritization**
|
|
||||||
|
|
||||||
Fixed critical bug in production search where exact matches weren't appearing first in search results.
|
|
||||||
|
|
||||||
#### Problem
|
|
||||||
- SQL ORDER BY clause was `ORDER BY rank, CASE ... END` (wrong order)
|
|
||||||
- FTS5 rank sorted first, CASE statement only acted as tiebreaker
|
|
||||||
- Since FTS5 ranks are always unique, CASE boosting never applied
|
|
||||||
- Additionally, CASE used case-sensitive comparison failing to match nodes like "Webhook" when searching "webhook"
|
|
||||||
- Result: Searching "webhook" returned "Webflow Trigger" first, actual "Webhook" node ranked 4th
|
|
||||||
|
|
||||||
#### Root Cause Analysis
|
|
||||||
**SQL Ordering Issue:**
|
|
||||||
```sql
|
|
||||||
-- BEFORE (Broken):
|
|
||||||
ORDER BY rank, CASE ... END -- rank first, CASE never used
|
|
||||||
-- Result: webhook ranks 4th (-9.64 rank)
|
|
||||||
-- Top 3: webflowTrigger (-10.20), vonage (-10.09), renameKeys (-10.01)
|
|
||||||
|
|
||||||
-- AFTER (Fixed):
|
|
||||||
ORDER BY CASE ... END, rank -- CASE first, exact matches prioritized
|
|
||||||
-- Result: webhook ranks 1st (CASE priority 0)
|
|
||||||
```
|
|
||||||
|
|
||||||
**Case-Sensitivity Issue:**
|
|
||||||
- Old: `WHEN n.display_name = ?` (case-sensitive, fails on "Webhook" vs "webhook")
|
|
||||||
- New: `WHEN LOWER(n.display_name) = LOWER(?)` (case-insensitive, matches correctly)
|
|
||||||
|
|
||||||
#### Fixed
|
|
||||||
|
|
||||||
**1. Production Code** (`src/mcp/server.ts` lines 1278-1295)
|
|
||||||
- Changed ORDER BY from: `rank, CASE ... END`
|
|
||||||
- To: `CASE WHEN LOWER(n.display_name) = LOWER(?) ... END, rank`
|
|
||||||
- Added case-insensitive comparison with LOWER() function
|
|
||||||
- Exact matches now consistently appear first in search results
|
|
||||||
|
|
||||||
**2. Test Files Updated**
|
|
||||||
- `tests/integration/database/node-fts5-search.test.ts` (lines 137-160)
|
|
||||||
- `tests/integration/ci/database-population.test.ts` (lines 206-234)
|
|
||||||
- Both updated to match corrected SQL logic with case-insensitive comparison
|
|
||||||
- Tests now accurately validate production search behavior
|
|
||||||
|
|
||||||
#### Impact
|
|
||||||
|
|
||||||
**Search Quality:**
|
|
||||||
- ✅ Exact matches now always rank first (webhook, http, code, etc.)
|
|
||||||
- ✅ Case-insensitive matching works correctly (Webhook = webhook = WEBHOOK)
|
|
||||||
- ✅ Better user experience - predictable search results
|
|
||||||
- ✅ SQL query more efficient (correct ordering at database level)
|
|
||||||
|
|
||||||
**Performance:**
|
|
||||||
- Same or better performance (less JavaScript sorting needed)
|
|
||||||
- Database does the heavy lifting with correct ORDER BY
|
|
||||||
- JavaScript sorting still provides additional relevance refinement
|
|
||||||
|
|
||||||
**Testing:**
|
|
||||||
- All 705 tests passing (703 passed + 2 fixed)
|
|
||||||
- Comprehensive testing by n8n-mcp-tester agent
|
|
||||||
- Code review approved with minor optimization suggestions for future
|
|
||||||
|
|
||||||
**Verified Search Results:**
|
|
||||||
- "webhook" → nodes-base.webhook (1st)
|
|
||||||
- "http" → nodes-base.httpRequest (1st)
|
|
||||||
- "code" → nodes-base.code (1st)
|
|
||||||
- "slack" → nodes-base.slack (1st)
|
|
||||||
- All case variations work correctly (WEBHOOK, Webhook, webhook)
|
|
||||||
|
|
||||||
## [2.20.6] - 2025-10-21
|
|
||||||
|
|
||||||
### 🐛 Bug Fixes
|
|
||||||
|
|
||||||
**Issue #342: Missing `tslib` Dependency Causing MODULE_NOT_FOUND on Windows**
|
|
||||||
|
|
||||||
Fixed critical dependency issue where `tslib` was missing from the published npm package, causing immediate failure when users ran `npx n8n-mcp@latest` on Windows (and potentially other platforms).
|
|
||||||
|
|
||||||
#### Problem
|
|
||||||
|
|
||||||
Users installing via `npx n8n-mcp@latest` experienced MODULE_NOT_FOUND errors:
|
|
||||||
```
|
|
||||||
Error: Cannot find module 'tslib'
|
|
||||||
Require stack:
|
|
||||||
- node_modules/@supabase/functions-js/dist/main/FunctionsClient.js
|
|
||||||
- node_modules/@supabase/supabase-js/dist/main/index.js
|
|
||||||
- node_modules/n8n-mcp/dist/telemetry/telemetry-manager.js
|
|
||||||
```
|
|
||||||
|
|
||||||
**Root Cause Analysis:**
|
|
||||||
- `@supabase/supabase-js` depends on `@supabase/functions-js` which requires `tslib` at runtime
|
|
||||||
- `tslib` was NOT explicitly listed in `package.runtime.json` dependencies
|
|
||||||
- The publish script (`scripts/publish-npm.sh`) copies `package.runtime.json` → `package.json` before publishing to npm
|
|
||||||
- CI/CD workflow (`.github/workflows/release.yml` line 329) does the same: `cp package.runtime.json $PUBLISH_DIR/package.json`
|
|
||||||
- Result: Published npm package had no `tslib` dependency
|
|
||||||
- When users installed via `npx`, npm didn't install `tslib` → MODULE_NOT_FOUND error
|
|
||||||
|
|
||||||
**Why It Worked Locally:**
|
|
||||||
- Local development uses main `package.json` which has full n8n package dependencies
|
|
||||||
- `tslib` existed as a transitive dependency through AWS SDK packages
|
|
||||||
- npm's hoisting made it available locally
|
|
||||||
|
|
||||||
**Why It Failed in Production:**
|
|
||||||
- `npx` installations use the published package (which comes from `package.runtime.json`)
|
|
||||||
- No transitive path to `tslib` in the minimal runtime dependencies
|
|
||||||
- npm's dependency resolution on Windows didn't hoist it properly
|
|
||||||
|
|
||||||
**Why Docker Worked:**
|
|
||||||
- Docker builds used `package-lock.json` which included all transitive dependencies
|
|
||||||
- Or the base image already had `tslib` installed
|
|
||||||
|
|
||||||
#### Fixed
|
|
||||||
|
|
||||||
**1. Added `tslib` to Runtime Dependencies**
|
|
||||||
- Added `"tslib": "^2.6.2"` to `package.runtime.json` dependencies (line 14)
|
|
||||||
- This is the **critical fix** since `package.runtime.json` gets published to npm
|
|
||||||
- Version `^2.6.2` matches existing transitive dependency versions
|
|
||||||
|
|
||||||
**2. Added `tslib` to Development Dependencies**
|
|
||||||
- Added `"tslib": "^2.6.2"` to `package.json` dependencies (line 154)
|
|
||||||
- Ensures consistency between development and production
|
|
||||||
- Prevents confusion for developers
|
|
||||||
|
|
||||||
**3. Synced `package.runtime.json` Version**
|
|
||||||
- Updated `package.runtime.json` version from `2.20.2` to `2.20.5`
|
|
||||||
- Keeps runtime package version in sync with main package version
|
|
||||||
|
|
||||||
#### Technical Details
|
|
||||||
|
|
||||||
**Dependency Chain:**
|
|
||||||
```
|
|
||||||
n8n-mcp
|
|
||||||
└── @supabase/supabase-js@2.57.4
|
|
||||||
└── @supabase/functions-js@2.4.6
|
|
||||||
└── tslib (MISSING) ❌
|
|
||||||
```
|
|
||||||
|
|
||||||
**Publish Process:**
|
|
||||||
```bash
|
|
||||||
# CI/CD workflow (.github/workflows/release.yml:329)
|
|
||||||
cp package.runtime.json $PUBLISH_DIR/package.json
|
|
||||||
npm publish --access public
|
|
||||||
|
|
||||||
# Users install via npx
|
|
||||||
npx n8n-mcp@latest
|
|
||||||
# → Gets dependencies from package.runtime.json (now includes tslib ✅)
|
|
||||||
```
|
|
||||||
|
|
||||||
**Files Modified:**
|
|
||||||
- `package.json` line 154: Added `tslib: "^2.6.2"`
|
|
||||||
- `package.runtime.json` line 14: Added `tslib: "^2.6.2"` (critical fix)
|
|
||||||
- `package.runtime.json` line 3: Updated version `2.20.2` → `2.20.5`
|
|
||||||
|
|
||||||
#### Impact
|
|
||||||
|
|
||||||
**Before Fix:**
|
|
||||||
- ❌ Package completely broken on Windows for `npx` users
|
|
||||||
- ❌ Affected all platforms using `npx` (not just Windows)
|
|
||||||
- ❌ 100% failure rate on fresh installations
|
|
||||||
- ❌ Workaround: Use v2.19.6 or install with `npm install` + run locally
|
|
||||||
|
|
||||||
**After Fix:**
|
|
||||||
- ✅ `npx n8n-mcp@latest` works on all platforms
|
|
||||||
- ✅ `tslib` guaranteed to be installed with the package
|
|
||||||
- ✅ No breaking changes (adding a dependency that was already in transitive tree)
|
|
||||||
- ✅ Consistent behavior across Windows, macOS, Linux
|
|
||||||
|
|
||||||
#### Verification
|
|
||||||
|
|
||||||
**Build & Tests:**
|
|
||||||
- ✅ TypeScript compilation passes
|
|
||||||
- ✅ Type checking passes (`npm run typecheck`)
|
|
||||||
- ✅ All tests pass
|
|
||||||
- ✅ Build succeeds (`npm run build`)
|
|
||||||
|
|
||||||
**CI/CD Validation:**
|
|
||||||
- ✅ Verified CI workflow copies `package.runtime.json` → `package.json` before publish
|
|
||||||
- ✅ Confirmed `tslib` will be included in published package
|
|
||||||
- ✅ No changes needed to CI/CD workflows
|
|
||||||
|
|
||||||
#### Related
|
|
||||||
|
|
||||||
- **Issue:** #342 - Missing `tslib` dependency in v2.20.3 causing MODULE_NOT_FOUND error on Windows
|
|
||||||
- **Reporter:** @eddyc (thank you for the detailed bug report!)
|
|
||||||
- **Severity:** CRITICAL - Package unusable via `npx` on Windows
|
|
||||||
- **Affected Versions:** 2.20.0 - 2.20.5
|
|
||||||
- **Fixed Version:** 2.20.6
|
|
||||||
|
|
||||||
Conceived by Romuald Członkowski - [www.aiadvisors.pl/en](https://www.aiadvisors.pl/en)
|
|
||||||
|
|
||||||
## [2.20.5] - 2025-10-21
|
|
||||||
|
|
||||||
### 🐛 Bug Fixes
|
|
||||||
|
|
||||||
**Validation False Positives Eliminated (80% → 0%)**
|
|
||||||
|
|
||||||
This release completely eliminates validation false positives on production workflows through comprehensive improvements to expression detection, webhook validation, and validation profile handling.
|
|
||||||
|
|
||||||
#### Problem Statement
|
|
||||||
|
|
||||||
Production workflows were experiencing an 80% false positive rate during validation:
|
|
||||||
- Expression-based URLs flagged as invalid (e.g., `={{ $json.protocol }}://{{ $json.domain }}/api`)
|
|
||||||
- Expression-based JSON flagged as invalid (e.g., `={{ { key: $json.value } }}`)
|
|
||||||
- Webhook `onError` validation checking wrong property location (node-level vs parameters)
|
|
||||||
- "Missing $ prefix" regex flagging valid property access (e.g., `item['json']`)
|
|
||||||
- `respondToWebhook` nodes incorrectly warned about missing error handling
|
|
||||||
- Hardcoded credential warnings appearing in all validation profiles
|
|
||||||
|
|
||||||
#### Solution Overview
|
|
||||||
|
|
||||||
**Phase 1: Centralized Expression Detection**
|
|
||||||
- Created `src/utils/expression-utils.ts` with 5 core utilities:
|
|
||||||
- `isExpression()`: Type predicate detecting `=` prefix
|
|
||||||
- `containsExpression()`: Detects `{{ }}` markers (optimized with single regex)
|
|
||||||
- `shouldSkipLiteralValidation()`: Main decision utility for validators
|
|
||||||
- `extractExpressionContent()`: Extracts expression code
|
|
||||||
- `hasMixedContent()`: Detects mixed text+expression patterns
|
|
||||||
- Added comprehensive test suite with 75 tests (100% statement coverage)
|
|
||||||
|
|
||||||
**Phase 2: URL and JSON Validation Fixes**
|
|
||||||
- Modified `config-validator.ts` to skip expression validation:
|
|
||||||
- URL validation: Skip when `shouldSkipLiteralValidation()` returns true (lines 385-397)
|
|
||||||
- JSON validation: Skip when value contains expressions (lines 424-439)
|
|
||||||
- Improved error messages to include actual JSON parse errors
|
|
||||||
|
|
||||||
**Phase 3: Webhook Validation Improvements**
|
|
||||||
- Fixed `onError` property location check in `workflow-validator.ts`:
|
|
||||||
- Now checks node-level `onError` property, not `parameters.onError`
|
|
||||||
- Added context-aware validation for webhook response modes
|
|
||||||
- Created specialized `checkWebhookErrorHandling()` helper method (lines 1618-1662):
|
|
||||||
- Skips validation for `respondToWebhook` nodes (response nodes)
|
|
||||||
- Requires `onError` for `responseNode` mode
|
|
||||||
- Provides warnings for regular webhook nodes
|
|
||||||
- Moved responseNode validation from `node-specific-validators.ts` to `workflow-validator.ts`
|
|
||||||
|
|
||||||
**Phase 4: Regex Pattern Enhancement**
|
|
||||||
- Updated missing prefix pattern in `expression-validator.ts` (line 217):
|
|
||||||
- Old: `/(?<!\$|\.)\b(json|node)\b/`
|
|
||||||
- New: `/(?<![.$\w['])\b(json|node|input|items|workflow|execution)\b(?!\s*[:''])/`
|
|
||||||
- Now correctly excludes:
|
|
||||||
- Dollar prefix: `$json` ✓
|
|
||||||
- Dot access: `.json` ✓
|
|
||||||
- Word chars: `myJson` ✓
|
|
||||||
- Bracket notation: `item['json']` ✓
|
|
||||||
- After quotes: `"json"` ✓
|
|
||||||
|
|
||||||
**Phase 5: Profile-Based Filtering**
|
|
||||||
- Made hardcoded credential warnings configurable in `enhanced-config-validator.ts`:
|
|
||||||
- Created `shouldFilterCredentialWarning()` helper method (lines 469-476)
|
|
||||||
- Only show hardcoded credential warnings in `strict` profile
|
|
||||||
- Filters warnings in `minimal`, `runtime`, and `ai-friendly` profiles
|
|
||||||
- Replaced 3 instances of duplicate filtering code (lines 492, 510, 539)
|
|
||||||
|
|
||||||
**Phase 6: Code Quality Improvements**
|
|
||||||
- Fixed type guard order in `hasMixedContent()` (line 90)
|
|
||||||
- Added type predicate to `isExpression()` for better TypeScript narrowing
|
|
||||||
- Extracted helper methods to reduce code duplication
|
|
||||||
- Improved error messages with actual parsing details
|
|
||||||
|
|
||||||
**Phase 7: Comprehensive Testing**
|
|
||||||
- Created `tests/unit/utils/expression-utils.test.ts` with 75 tests:
|
|
||||||
- `isExpression()`: 18 tests (valid, invalid, edge cases, type narrowing)
|
|
||||||
- `containsExpression()`: 14 tests (markers, edge cases)
|
|
||||||
- `shouldSkipLiteralValidation()`: 12 tests (skip conditions, real-world)
|
|
||||||
- `extractExpressionContent()`: 11 tests (extraction, edge cases)
|
|
||||||
- `hasMixedContent()`: 19 tests (mixed content, type guards)
|
|
||||||
- Integration scenarios: 4 tests (real workflow scenarios)
|
|
||||||
- Performance test: 10k iterations in <100ms
|
|
||||||
- Fixed CI test failure by skipping moved validation tests in `node-specific-validators.test.ts`
|
|
||||||
|
|
||||||
#### Results
|
|
||||||
|
|
||||||
**Validation Accuracy:**
|
|
||||||
- Total Errors: 16 → 0 (100% elimination)
|
|
||||||
- Total Warnings: 45 → 27 (40% reduction)
|
|
||||||
- Valid Workflows: 0/6 → 6/6 (100% success rate)
|
|
||||||
- False Positive Rate: 80% → 0%
|
|
||||||
|
|
||||||
**Test Coverage:**
|
|
||||||
- New tests: 75 comprehensive test cases
|
|
||||||
- Statement coverage: 100%
|
|
||||||
- Line coverage: 100%
|
|
||||||
- Branch coverage: 95.23%
|
|
||||||
- All 143 tests passing ✓
|
|
||||||
|
|
||||||
**Files Changed:**
|
|
||||||
- Modified: 7 files
|
|
||||||
- `src/services/config-validator.ts`
|
|
||||||
- `src/services/enhanced-config-validator.ts`
|
|
||||||
- `src/services/expression-validator.ts`
|
|
||||||
- `src/services/workflow-validator.ts`
|
|
||||||
- `src/services/node-specific-validators.ts`
|
|
||||||
- `tests/unit/services/node-specific-validators.test.ts`
|
|
||||||
- Created: 2 files
|
|
||||||
- `src/utils/expression-utils.ts`
|
|
||||||
- `tests/unit/utils/expression-utils.test.ts`
|
|
||||||
|
|
||||||
**Code Review:**
|
|
||||||
- ✅ READY TO MERGE
|
|
||||||
- All phases implemented with critical warnings and suggestions addressed
|
|
||||||
- Type safety improved with type predicates
|
|
||||||
- Code duplication eliminated with helper methods
|
|
||||||
- Comprehensive test coverage with real-world scenarios
|
|
||||||
|
|
||||||
**Related:**
|
|
||||||
- PR #346
|
|
||||||
- Branch: `feat/sticky-note-validation`
|
|
||||||
|
|
||||||
Conceived by Romuald Członkowski - [www.aiadvisors.pl/en](https://www.aiadvisors.pl/en)
|
|
||||||
|
|
||||||
## [2.20.4] - 2025-10-21
|
## [2.20.4] - 2025-10-21
|
||||||
|
|
||||||
### 🛡️ Safety & Reliability Enhancements
|
### 🛡️ Safety & Reliability Enhancements
|
||||||
|
|||||||
@@ -193,4 +193,3 @@ NEVER proactively create documentation files (*.md) or README files. Only create
|
|||||||
- When the task can be divided into separated subtasks, you should spawn separate sub-agents to handle them in paralel
|
- When the task can be divided into separated subtasks, you should spawn separate sub-agents to handle them in paralel
|
||||||
- Use the best sub-agent for the task as per their descriptions
|
- Use the best sub-agent for the task as per their descriptions
|
||||||
- Do not use hyperbolic or dramatic language in comments and documentation
|
- Do not use hyperbolic or dramatic language in comments and documentation
|
||||||
- Add to every commit and PR: Concieved by Romuald Członkowski - and then link to www.aiadvisors.pl/en. Don't add it in conversations
|
|
||||||
@@ -5,7 +5,7 @@
|
|||||||
[](https://www.npmjs.com/package/n8n-mcp)
|
[](https://www.npmjs.com/package/n8n-mcp)
|
||||||
[](https://codecov.io/gh/czlonkowski/n8n-mcp)
|
[](https://codecov.io/gh/czlonkowski/n8n-mcp)
|
||||||
[](https://github.com/czlonkowski/n8n-mcp/actions)
|
[](https://github.com/czlonkowski/n8n-mcp/actions)
|
||||||
[](https://github.com/n8n-io/n8n)
|
[](https://github.com/n8n-io/n8n)
|
||||||
[](https://github.com/czlonkowski/n8n-mcp/pkgs/container/n8n-mcp)
|
[](https://github.com/czlonkowski/n8n-mcp/pkgs/container/n8n-mcp)
|
||||||
[](https://railway.com/deploy/n8n-mcp?referralCode=n8n-mcp)
|
[](https://railway.com/deploy/n8n-mcp?referralCode=n8n-mcp)
|
||||||
|
|
||||||
|
|||||||
BIN
data/nodes.db
BIN
data/nodes.db
Binary file not shown.
5997
package-lock.json
generated
5997
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
11
package.json
11
package.json
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "n8n-mcp",
|
"name": "n8n-mcp",
|
||||||
"version": "2.20.8",
|
"version": "2.20.4",
|
||||||
"description": "Integration between n8n workflow automation and Model Context Protocol (MCP)",
|
"description": "Integration between n8n workflow automation and Model Context Protocol (MCP)",
|
||||||
"main": "dist/index.js",
|
"main": "dist/index.js",
|
||||||
"types": "dist/index.d.ts",
|
"types": "dist/index.d.ts",
|
||||||
@@ -140,18 +140,17 @@
|
|||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@modelcontextprotocol/sdk": "^1.20.1",
|
"@modelcontextprotocol/sdk": "^1.20.1",
|
||||||
"@n8n/n8n-nodes-langchain": "^1.115.1",
|
"@n8n/n8n-nodes-langchain": "^1.114.1",
|
||||||
"@supabase/supabase-js": "^2.57.4",
|
"@supabase/supabase-js": "^2.57.4",
|
||||||
"dotenv": "^16.5.0",
|
"dotenv": "^16.5.0",
|
||||||
"express": "^5.1.0",
|
"express": "^5.1.0",
|
||||||
"express-rate-limit": "^7.1.5",
|
"express-rate-limit": "^7.1.5",
|
||||||
"lru-cache": "^11.2.1",
|
"lru-cache": "^11.2.1",
|
||||||
"n8n": "^1.116.2",
|
"n8n": "^1.115.2",
|
||||||
"n8n-core": "^1.115.1",
|
"n8n-core": "^1.114.0",
|
||||||
"n8n-workflow": "^1.113.0",
|
"n8n-workflow": "^1.112.0",
|
||||||
"openai": "^4.77.0",
|
"openai": "^4.77.0",
|
||||||
"sql.js": "^1.13.0",
|
"sql.js": "^1.13.0",
|
||||||
"tslib": "^2.6.2",
|
|
||||||
"uuid": "^10.0.0",
|
"uuid": "^10.0.0",
|
||||||
"zod": "^3.24.1"
|
"zod": "^3.24.1"
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "n8n-mcp-runtime",
|
"name": "n8n-mcp-runtime",
|
||||||
"version": "2.20.7",
|
"version": "2.20.2",
|
||||||
"description": "n8n MCP Server Runtime Dependencies Only",
|
"description": "n8n MCP Server Runtime Dependencies Only",
|
||||||
"private": true,
|
"private": true,
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
@@ -11,7 +11,6 @@
|
|||||||
"dotenv": "^16.5.0",
|
"dotenv": "^16.5.0",
|
||||||
"lru-cache": "^11.2.1",
|
"lru-cache": "^11.2.1",
|
||||||
"sql.js": "^1.13.0",
|
"sql.js": "^1.13.0",
|
||||||
"tslib": "^2.6.2",
|
|
||||||
"uuid": "^10.0.0",
|
"uuid": "^10.0.0",
|
||||||
"axios": "^1.7.7"
|
"axios": "^1.7.7"
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -1283,13 +1283,13 @@ export class N8NDocumentationMCPServer {
|
|||||||
JOIN nodes_fts ON n.rowid = nodes_fts.rowid
|
JOIN nodes_fts ON n.rowid = nodes_fts.rowid
|
||||||
WHERE nodes_fts MATCH ?
|
WHERE nodes_fts MATCH ?
|
||||||
ORDER BY
|
ORDER BY
|
||||||
|
rank,
|
||||||
CASE
|
CASE
|
||||||
WHEN LOWER(n.display_name) = LOWER(?) THEN 0
|
WHEN n.display_name = ? THEN 0
|
||||||
WHEN LOWER(n.display_name) LIKE LOWER(?) THEN 1
|
WHEN n.display_name LIKE ? THEN 1
|
||||||
WHEN LOWER(n.node_type) LIKE LOWER(?) THEN 2
|
WHEN n.node_type LIKE ? THEN 2
|
||||||
ELSE 3
|
ELSE 3
|
||||||
END,
|
END,
|
||||||
rank,
|
|
||||||
n.display_name
|
n.display_name
|
||||||
LIMIT ?
|
LIMIT ?
|
||||||
`).all(ftsQuery, cleanedQuery, `%${cleanedQuery}%`, `%${cleanedQuery}%`, limit) as (NodeRow & { rank: number })[];
|
`).all(ftsQuery, cleanedQuery, `%${cleanedQuery}%`, `%${cleanedQuery}%`, limit) as (NodeRow & { rank: number })[];
|
||||||
|
|||||||
@@ -5,8 +5,6 @@
|
|||||||
* Provides helpful suggestions and identifies missing or misconfigured properties.
|
* Provides helpful suggestions and identifies missing or misconfigured properties.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import { shouldSkipLiteralValidation } from '../utils/expression-utils.js';
|
|
||||||
|
|
||||||
export interface ValidationResult {
|
export interface ValidationResult {
|
||||||
valid: boolean;
|
valid: boolean;
|
||||||
errors: ValidationError[];
|
errors: ValidationError[];
|
||||||
@@ -383,16 +381,13 @@ export class ConfigValidator {
|
|||||||
): void {
|
): void {
|
||||||
// URL validation
|
// URL validation
|
||||||
if (config.url && typeof config.url === 'string') {
|
if (config.url && typeof config.url === 'string') {
|
||||||
// Skip validation for expressions - they will be evaluated at runtime
|
if (!config.url.startsWith('http://') && !config.url.startsWith('https://')) {
|
||||||
if (!shouldSkipLiteralValidation(config.url)) {
|
errors.push({
|
||||||
if (!config.url.startsWith('http://') && !config.url.startsWith('https://')) {
|
type: 'invalid_value',
|
||||||
errors.push({
|
property: 'url',
|
||||||
type: 'invalid_value',
|
message: 'URL must start with http:// or https://',
|
||||||
property: 'url',
|
fix: 'Add https:// to the beginning of your URL'
|
||||||
message: 'URL must start with http:// or https://',
|
});
|
||||||
fix: 'Add https:// to the beginning of your URL'
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -422,19 +417,15 @@ export class ConfigValidator {
|
|||||||
|
|
||||||
// JSON body validation
|
// JSON body validation
|
||||||
if (config.sendBody && config.contentType === 'json' && config.jsonBody) {
|
if (config.sendBody && config.contentType === 'json' && config.jsonBody) {
|
||||||
// Skip validation for expressions - they will be evaluated at runtime
|
try {
|
||||||
if (!shouldSkipLiteralValidation(config.jsonBody)) {
|
JSON.parse(config.jsonBody);
|
||||||
try {
|
} catch (e) {
|
||||||
JSON.parse(config.jsonBody);
|
errors.push({
|
||||||
} catch (e) {
|
type: 'invalid_value',
|
||||||
const errorMsg = e instanceof Error ? e.message : 'Unknown parsing error';
|
property: 'jsonBody',
|
||||||
errors.push({
|
message: 'jsonBody contains invalid JSON',
|
||||||
type: 'invalid_value',
|
fix: 'Ensure jsonBody contains valid JSON syntax'
|
||||||
property: 'jsonBody',
|
});
|
||||||
message: `jsonBody contains invalid JSON: ${errorMsg}`,
|
|
||||||
fix: 'Fix JSON syntax error and ensure valid JSON format'
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -466,15 +466,6 @@ export class EnhancedConfigValidator extends ConfigValidator {
|
|||||||
return Array.from(seen.values());
|
return Array.from(seen.values());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Check if a warning should be filtered out (hardcoded credentials shown only in strict mode)
|
|
||||||
*/
|
|
||||||
private static shouldFilterCredentialWarning(warning: ValidationWarning): boolean {
|
|
||||||
return warning.type === 'security' &&
|
|
||||||
warning.message !== undefined &&
|
|
||||||
warning.message.includes('Hardcoded nodeCredentialType');
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Apply profile-based filtering to validation results
|
* Apply profile-based filtering to validation results
|
||||||
*/
|
*/
|
||||||
@@ -487,13 +478,9 @@ export class EnhancedConfigValidator extends ConfigValidator {
|
|||||||
// Only keep missing required errors
|
// Only keep missing required errors
|
||||||
result.errors = result.errors.filter(e => e.type === 'missing_required');
|
result.errors = result.errors.filter(e => e.type === 'missing_required');
|
||||||
// Keep ONLY critical warnings (security and deprecated)
|
// Keep ONLY critical warnings (security and deprecated)
|
||||||
// But filter out hardcoded credential type warnings (only show in strict mode)
|
result.warnings = result.warnings.filter(w =>
|
||||||
result.warnings = result.warnings.filter(w => {
|
w.type === 'security' || w.type === 'deprecated'
|
||||||
if (this.shouldFilterCredentialWarning(w)) {
|
);
|
||||||
return false;
|
|
||||||
}
|
|
||||||
return w.type === 'security' || w.type === 'deprecated';
|
|
||||||
});
|
|
||||||
result.suggestions = [];
|
result.suggestions = [];
|
||||||
break;
|
break;
|
||||||
|
|
||||||
@@ -506,10 +493,6 @@ export class EnhancedConfigValidator extends ConfigValidator {
|
|||||||
);
|
);
|
||||||
// Keep security and deprecated warnings, REMOVE property visibility warnings
|
// Keep security and deprecated warnings, REMOVE property visibility warnings
|
||||||
result.warnings = result.warnings.filter(w => {
|
result.warnings = result.warnings.filter(w => {
|
||||||
// Filter out hardcoded credential type warnings (only show in strict mode)
|
|
||||||
if (this.shouldFilterCredentialWarning(w)) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
if (w.type === 'security' || w.type === 'deprecated') return true;
|
if (w.type === 'security' || w.type === 'deprecated') return true;
|
||||||
// FILTER OUT property visibility warnings (too noisy)
|
// FILTER OUT property visibility warnings (too noisy)
|
||||||
if (w.type === 'inefficient' && w.message && w.message.includes('not visible')) {
|
if (w.type === 'inefficient' && w.message && w.message.includes('not visible')) {
|
||||||
@@ -535,10 +518,6 @@ export class EnhancedConfigValidator extends ConfigValidator {
|
|||||||
// Current behavior - balanced for AI agents
|
// Current behavior - balanced for AI agents
|
||||||
// Filter out noise but keep helpful warnings
|
// Filter out noise but keep helpful warnings
|
||||||
result.warnings = result.warnings.filter(w => {
|
result.warnings = result.warnings.filter(w => {
|
||||||
// Filter out hardcoded credential type warnings (only show in strict mode)
|
|
||||||
if (this.shouldFilterCredentialWarning(w)) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
// Keep security and deprecated warnings
|
// Keep security and deprecated warnings
|
||||||
if (w.type === 'security' || w.type === 'deprecated') return true;
|
if (w.type === 'security' || w.type === 'deprecated') return true;
|
||||||
// Keep missing common properties
|
// Keep missing common properties
|
||||||
|
|||||||
@@ -207,14 +207,8 @@ export class ExpressionValidator {
|
|||||||
expr: string,
|
expr: string,
|
||||||
result: ExpressionValidationResult
|
result: ExpressionValidationResult
|
||||||
): void {
|
): void {
|
||||||
// Check for missing $ prefix - but exclude cases where $ is already present OR it's property access (e.g., .json)
|
// Check for missing $ prefix - but exclude cases where $ is already present
|
||||||
// The pattern now excludes:
|
const missingPrefixPattern = /(?<!\$)\b(json|node|input|items|workflow|execution)\b(?!\s*:)/;
|
||||||
// - Immediately preceded by $ (e.g., $json) - handled by (?<!\$)
|
|
||||||
// - Preceded by a dot (e.g., .json in $('Node').item.json.field) - handled by (?<!\.)
|
|
||||||
// - Inside word characters (e.g., myJson) - handled by (?<!\w)
|
|
||||||
// - Inside bracket notation (e.g., ['json']) - handled by (?<![)
|
|
||||||
// - After opening bracket or quote (e.g., "json" or ['json'])
|
|
||||||
const missingPrefixPattern = /(?<![.$\w['])\b(json|node|input|items|workflow|execution)\b(?!\s*[:''])/;
|
|
||||||
if (expr.match(missingPrefixPattern)) {
|
if (expr.match(missingPrefixPattern)) {
|
||||||
result.warnings.push(
|
result.warnings.push(
|
||||||
'Possible missing $ prefix for variable (e.g., use $json instead of json)'
|
'Possible missing $ prefix for variable (e.g., use $json instead of json)'
|
||||||
|
|||||||
@@ -1,6 +1,5 @@
|
|||||||
import { z } from 'zod';
|
import { z } from 'zod';
|
||||||
import { WorkflowNode, WorkflowConnection, Workflow } from '../types/n8n-api';
|
import { WorkflowNode, WorkflowConnection, Workflow } from '../types/n8n-api';
|
||||||
import { isNonExecutableNode, isTriggerNode } from '../utils/node-classification';
|
|
||||||
|
|
||||||
// Zod schemas for n8n API validation
|
// Zod schemas for n8n API validation
|
||||||
|
|
||||||
@@ -195,14 +194,6 @@ export function validateWorkflowStructure(workflow: Partial<Workflow>): string[]
|
|||||||
errors.push('Workflow must have at least one node');
|
errors.push('Workflow must have at least one node');
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check if workflow has only non-executable nodes (sticky notes)
|
|
||||||
if (workflow.nodes && workflow.nodes.length > 0) {
|
|
||||||
const hasExecutableNodes = workflow.nodes.some(node => !isNonExecutableNode(node.type));
|
|
||||||
if (!hasExecutableNodes) {
|
|
||||||
errors.push('Workflow must have at least one executable node. Sticky notes alone cannot form a valid workflow.');
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!workflow.connections) {
|
if (!workflow.connections) {
|
||||||
errors.push('Workflow connections are required');
|
errors.push('Workflow connections are required');
|
||||||
}
|
}
|
||||||
@@ -220,15 +211,13 @@ export function validateWorkflowStructure(workflow: Partial<Workflow>): string[]
|
|||||||
|
|
||||||
// Check for disconnected nodes in multi-node workflows
|
// Check for disconnected nodes in multi-node workflows
|
||||||
if (workflow.nodes && workflow.nodes.length > 1 && workflow.connections) {
|
if (workflow.nodes && workflow.nodes.length > 1 && workflow.connections) {
|
||||||
// Filter out non-executable nodes (sticky notes) when counting nodes
|
|
||||||
const executableNodes = workflow.nodes.filter(node => !isNonExecutableNode(node.type));
|
|
||||||
const connectionCount = Object.keys(workflow.connections).length;
|
const connectionCount = Object.keys(workflow.connections).length;
|
||||||
|
|
||||||
// First check: workflow has no connections at all (only check if there are multiple executable nodes)
|
// First check: workflow has no connections at all
|
||||||
if (connectionCount === 0 && executableNodes.length > 1) {
|
if (connectionCount === 0) {
|
||||||
const nodeNames = executableNodes.slice(0, 2).map(n => n.name);
|
const nodeNames = workflow.nodes.slice(0, 2).map(n => n.name);
|
||||||
errors.push(`Multi-node workflow has no connections between nodes. Add a connection using: {type: 'addConnection', source: '${nodeNames[0]}', target: '${nodeNames[1]}', sourcePort: 'main', targetPort: 'main'}`);
|
errors.push(`Multi-node workflow has no connections between nodes. Add a connection using: {type: 'addConnection', source: '${nodeNames[0]}', target: '${nodeNames[1]}', sourcePort: 'main', targetPort: 'main'}`);
|
||||||
} else if (connectionCount > 0 || executableNodes.length > 1) {
|
} else {
|
||||||
// Second check: detect disconnected nodes (nodes with no incoming or outgoing connections)
|
// Second check: detect disconnected nodes (nodes with no incoming or outgoing connections)
|
||||||
const connectedNodes = new Set<string>();
|
const connectedNodes = new Set<string>();
|
||||||
|
|
||||||
@@ -247,20 +236,19 @@ export function validateWorkflowStructure(workflow: Partial<Workflow>): string[]
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
// Find disconnected nodes (excluding non-executable nodes and triggers)
|
// Find disconnected nodes (excluding webhook triggers which can be source-only)
|
||||||
// Non-executable nodes (sticky notes) are UI-only and don't need connections
|
const webhookTypes = new Set([
|
||||||
// Trigger nodes only need outgoing connections
|
'n8n-nodes-base.webhook',
|
||||||
|
'n8n-nodes-base.webhookTrigger',
|
||||||
|
'n8n-nodes-base.manualTrigger'
|
||||||
|
]);
|
||||||
|
|
||||||
const disconnectedNodes = workflow.nodes.filter(node => {
|
const disconnectedNodes = workflow.nodes.filter(node => {
|
||||||
// Skip non-executable nodes (sticky notes, etc.) - they're UI-only annotations
|
|
||||||
if (isNonExecutableNode(node.type)) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
const isConnected = connectedNodes.has(node.name);
|
const isConnected = connectedNodes.has(node.name);
|
||||||
const isTrigger = isTriggerNode(node.type);
|
const isWebhookOrTrigger = webhookTypes.has(node.type);
|
||||||
|
|
||||||
// Trigger nodes only need outgoing connections
|
// Webhook/trigger nodes only need outgoing connections
|
||||||
if (isTrigger) {
|
if (isWebhookOrTrigger) {
|
||||||
return !workflow.connections?.[node.name]; // Disconnected if no outgoing connections
|
return !workflow.connections?.[node.name]; // Disconnected if no outgoing connections
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1038,8 +1038,15 @@ export class NodeSpecificValidators {
|
|||||||
delete autofix.continueOnFail;
|
delete autofix.continueOnFail;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Note: responseNode mode validation moved to workflow-validator.ts
|
// Response mode validation
|
||||||
// where it has access to node-level onError property (not just config/parameters)
|
if (responseMode === 'responseNode' && !config.onError && !config.continueOnFail) {
|
||||||
|
errors.push({
|
||||||
|
type: 'invalid_configuration',
|
||||||
|
property: 'responseMode',
|
||||||
|
message: 'responseNode mode requires onError: "continueRegularOutput"',
|
||||||
|
fix: 'Set onError to ensure response is always sent'
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
// Always output data for debugging
|
// Always output data for debugging
|
||||||
if (!config.alwaysOutputData) {
|
if (!config.alwaysOutputData) {
|
||||||
|
|||||||
@@ -11,7 +11,6 @@ import { NodeSimilarityService, NodeSuggestion } from './node-similarity-service
|
|||||||
import { NodeTypeNormalizer } from '../utils/node-type-normalizer';
|
import { NodeTypeNormalizer } from '../utils/node-type-normalizer';
|
||||||
import { Logger } from '../utils/logger';
|
import { Logger } from '../utils/logger';
|
||||||
import { validateAISpecificNodes, hasAINodes } from './ai-node-validator';
|
import { validateAISpecificNodes, hasAINodes } from './ai-node-validator';
|
||||||
import { isNonExecutableNode } from '../utils/node-classification';
|
|
||||||
const logger = new Logger({ prefix: '[WorkflowValidator]' });
|
const logger = new Logger({ prefix: '[WorkflowValidator]' });
|
||||||
|
|
||||||
interface WorkflowNode {
|
interface WorkflowNode {
|
||||||
@@ -86,8 +85,17 @@ export class WorkflowValidator {
|
|||||||
this.similarityService = new NodeSimilarityService(nodeRepository);
|
this.similarityService = new NodeSimilarityService(nodeRepository);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Note: isStickyNote logic moved to shared utility: src/utils/node-classification.ts
|
/**
|
||||||
// Use isNonExecutableNode(node.type) instead
|
* Check if a node is a Sticky Note or other non-executable node
|
||||||
|
*/
|
||||||
|
private isStickyNote(node: WorkflowNode): boolean {
|
||||||
|
const stickyNoteTypes = [
|
||||||
|
'n8n-nodes-base.stickyNote',
|
||||||
|
'nodes-base.stickyNote',
|
||||||
|
'@n8n/n8n-nodes-base.stickyNote'
|
||||||
|
];
|
||||||
|
return stickyNoteTypes.includes(node.type);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Validate a complete workflow
|
* Validate a complete workflow
|
||||||
@@ -138,7 +146,7 @@ export class WorkflowValidator {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Update statistics after null check (exclude sticky notes from counts)
|
// Update statistics after null check (exclude sticky notes from counts)
|
||||||
const executableNodes = Array.isArray(workflow.nodes) ? workflow.nodes.filter(n => !isNonExecutableNode(n.type)) : [];
|
const executableNodes = Array.isArray(workflow.nodes) ? workflow.nodes.filter(n => !this.isStickyNote(n)) : [];
|
||||||
result.statistics.totalNodes = executableNodes.length;
|
result.statistics.totalNodes = executableNodes.length;
|
||||||
result.statistics.enabledNodes = executableNodes.filter(n => !n.disabled).length;
|
result.statistics.enabledNodes = executableNodes.filter(n => !n.disabled).length;
|
||||||
|
|
||||||
@@ -348,7 +356,7 @@ export class WorkflowValidator {
|
|||||||
profile: string
|
profile: string
|
||||||
): Promise<void> {
|
): Promise<void> {
|
||||||
for (const node of workflow.nodes) {
|
for (const node of workflow.nodes) {
|
||||||
if (node.disabled || isNonExecutableNode(node.type)) continue;
|
if (node.disabled || this.isStickyNote(node)) continue;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
// Validate node name length
|
// Validate node name length
|
||||||
@@ -624,7 +632,7 @@ export class WorkflowValidator {
|
|||||||
|
|
||||||
// Check for orphaned nodes (exclude sticky notes)
|
// Check for orphaned nodes (exclude sticky notes)
|
||||||
for (const node of workflow.nodes) {
|
for (const node of workflow.nodes) {
|
||||||
if (node.disabled || isNonExecutableNode(node.type)) continue;
|
if (node.disabled || this.isStickyNote(node)) continue;
|
||||||
|
|
||||||
const normalizedType = NodeTypeNormalizer.normalizeToFullForm(node.type);
|
const normalizedType = NodeTypeNormalizer.normalizeToFullForm(node.type);
|
||||||
const isTrigger = normalizedType.toLowerCase().includes('trigger') ||
|
const isTrigger = normalizedType.toLowerCase().includes('trigger') ||
|
||||||
@@ -869,7 +877,7 @@ export class WorkflowValidator {
|
|||||||
|
|
||||||
// Build node type map (exclude sticky notes)
|
// Build node type map (exclude sticky notes)
|
||||||
workflow.nodes.forEach(node => {
|
workflow.nodes.forEach(node => {
|
||||||
if (!isNonExecutableNode(node.type)) {
|
if (!this.isStickyNote(node)) {
|
||||||
nodeTypeMap.set(node.name, node.type);
|
nodeTypeMap.set(node.name, node.type);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@@ -937,7 +945,7 @@ export class WorkflowValidator {
|
|||||||
|
|
||||||
// Check from all executable nodes (exclude sticky notes)
|
// Check from all executable nodes (exclude sticky notes)
|
||||||
for (const node of workflow.nodes) {
|
for (const node of workflow.nodes) {
|
||||||
if (!isNonExecutableNode(node.type) && !visited.has(node.name)) {
|
if (!this.isStickyNote(node) && !visited.has(node.name)) {
|
||||||
if (hasCycleDFS(node.name)) return true;
|
if (hasCycleDFS(node.name)) return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -956,7 +964,7 @@ export class WorkflowValidator {
|
|||||||
const nodeNames = workflow.nodes.map(n => n.name);
|
const nodeNames = workflow.nodes.map(n => n.name);
|
||||||
|
|
||||||
for (const node of workflow.nodes) {
|
for (const node of workflow.nodes) {
|
||||||
if (node.disabled || isNonExecutableNode(node.type)) continue;
|
if (node.disabled || this.isStickyNote(node)) continue;
|
||||||
|
|
||||||
// Skip expression validation for langchain nodes
|
// Skip expression validation for langchain nodes
|
||||||
// They have AI-specific validators and different expression rules
|
// They have AI-specific validators and different expression rules
|
||||||
@@ -1103,7 +1111,7 @@ export class WorkflowValidator {
|
|||||||
|
|
||||||
// Check node-level error handling properties for ALL executable nodes
|
// Check node-level error handling properties for ALL executable nodes
|
||||||
for (const node of workflow.nodes) {
|
for (const node of workflow.nodes) {
|
||||||
if (!isNonExecutableNode(node.type)) {
|
if (!this.isStickyNote(node)) {
|
||||||
this.checkNodeErrorHandling(node, workflow, result);
|
this.checkNodeErrorHandling(node, workflow, result);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1284,15 +1292,6 @@ export class WorkflowValidator {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Check node-level error handling configuration for a single node
|
* Check node-level error handling configuration for a single node
|
||||||
*
|
|
||||||
* Validates error handling properties (onError, continueOnFail, retryOnFail)
|
|
||||||
* and provides warnings for error-prone nodes (HTTP, webhooks, databases)
|
|
||||||
* that lack proper error handling. Delegates webhook-specific validation
|
|
||||||
* to checkWebhookErrorHandling() for clearer logic.
|
|
||||||
*
|
|
||||||
* @param node - The workflow node to validate
|
|
||||||
* @param workflow - The complete workflow for context
|
|
||||||
* @param result - Validation result to add errors/warnings to
|
|
||||||
*/
|
*/
|
||||||
private checkNodeErrorHandling(
|
private checkNodeErrorHandling(
|
||||||
node: WorkflowNode,
|
node: WorkflowNode,
|
||||||
@@ -1503,8 +1502,12 @@ export class WorkflowValidator {
|
|||||||
message: 'HTTP Request node without error handling. Consider adding "onError: \'continueRegularOutput\'" for non-critical requests or "retryOnFail: true" for transient failures.'
|
message: 'HTTP Request node without error handling. Consider adding "onError: \'continueRegularOutput\'" for non-critical requests or "retryOnFail: true" for transient failures.'
|
||||||
});
|
});
|
||||||
} else if (normalizedType.includes('webhook')) {
|
} else if (normalizedType.includes('webhook')) {
|
||||||
// Delegate to specialized webhook validation helper
|
result.warnings.push({
|
||||||
this.checkWebhookErrorHandling(node, normalizedType, result);
|
type: 'warning',
|
||||||
|
nodeId: node.id,
|
||||||
|
nodeName: node.name,
|
||||||
|
message: 'Webhook node without error handling. Consider adding "onError: \'continueRegularOutput\'" to prevent workflow failures from blocking webhook responses.'
|
||||||
|
});
|
||||||
} else if (errorProneNodeTypes.some(db => normalizedType.includes(db) && ['postgres', 'mysql', 'mongodb'].includes(db))) {
|
} else if (errorProneNodeTypes.some(db => normalizedType.includes(db) && ['postgres', 'mysql', 'mongodb'].includes(db))) {
|
||||||
result.warnings.push({
|
result.warnings.push({
|
||||||
type: 'warning',
|
type: 'warning',
|
||||||
@@ -1595,52 +1598,6 @@ export class WorkflowValidator {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Check webhook-specific error handling requirements
|
|
||||||
*
|
|
||||||
* Webhooks have special error handling requirements:
|
|
||||||
* - respondToWebhook nodes (response nodes) don't need error handling
|
|
||||||
* - Webhook nodes with responseNode mode REQUIRE onError to ensure responses
|
|
||||||
* - Regular webhook nodes should have error handling to prevent blocking
|
|
||||||
*
|
|
||||||
* @param node - The webhook node to check
|
|
||||||
* @param normalizedType - Normalized node type for comparison
|
|
||||||
* @param result - Validation result to add errors/warnings to
|
|
||||||
*/
|
|
||||||
private checkWebhookErrorHandling(
|
|
||||||
node: WorkflowNode,
|
|
||||||
normalizedType: string,
|
|
||||||
result: WorkflowValidationResult
|
|
||||||
): void {
|
|
||||||
// respondToWebhook nodes are response nodes (endpoints), not triggers
|
|
||||||
// They're the END of execution, not controllers of flow - skip error handling check
|
|
||||||
if (normalizedType.includes('respondtowebhook')) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Check for responseNode mode specifically
|
|
||||||
// responseNode mode requires onError to ensure response is sent even on error
|
|
||||||
if (node.parameters?.responseMode === 'responseNode') {
|
|
||||||
if (!node.onError && !node.continueOnFail) {
|
|
||||||
result.errors.push({
|
|
||||||
type: 'error',
|
|
||||||
nodeId: node.id,
|
|
||||||
nodeName: node.name,
|
|
||||||
message: 'responseNode mode requires onError: "continueRegularOutput"'
|
|
||||||
});
|
|
||||||
}
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Regular webhook nodes without responseNode mode
|
|
||||||
result.warnings.push({
|
|
||||||
type: 'warning',
|
|
||||||
nodeId: node.id,
|
|
||||||
nodeName: node.name,
|
|
||||||
message: 'Webhook node without error handling. Consider adding "onError: \'continueRegularOutput\'" to prevent workflow failures from blocking webhook responses.'
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Generate error handling suggestions based on all nodes
|
* Generate error handling suggestions based on all nodes
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -1,109 +0,0 @@
|
|||||||
/**
|
|
||||||
* Utility functions for detecting and handling n8n expressions
|
|
||||||
*/
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Detects if a value is an n8n expression
|
|
||||||
*
|
|
||||||
* n8n expressions can be:
|
|
||||||
* - Pure expression: `={{ $json.value }}`
|
|
||||||
* - Mixed content: `=https://api.com/{{ $json.id }}/data`
|
|
||||||
* - Prefix-only: `=$json.value`
|
|
||||||
*
|
|
||||||
* @param value - The value to check
|
|
||||||
* @returns true if the value is an expression (starts with =)
|
|
||||||
*/
|
|
||||||
export function isExpression(value: unknown): value is string {
|
|
||||||
return typeof value === 'string' && value.startsWith('=');
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Detects if a string contains n8n expression syntax {{ }}
|
|
||||||
*
|
|
||||||
* This checks for expression markers within the string,
|
|
||||||
* regardless of whether it has the = prefix.
|
|
||||||
*
|
|
||||||
* @param value - The value to check
|
|
||||||
* @returns true if the value contains {{ }} markers
|
|
||||||
*/
|
|
||||||
export function containsExpression(value: unknown): boolean {
|
|
||||||
if (typeof value !== 'string') {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
// Use single regex for better performance than two includes()
|
|
||||||
return /\{\{.*\}\}/s.test(value);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Detects if a value should skip literal validation
|
|
||||||
*
|
|
||||||
* This is the main utility to use before validating values like URLs, JSON, etc.
|
|
||||||
* It returns true if:
|
|
||||||
* - The value is an expression (starts with =)
|
|
||||||
* - OR the value contains expression markers {{ }}
|
|
||||||
*
|
|
||||||
* @param value - The value to check
|
|
||||||
* @returns true if validation should be skipped
|
|
||||||
*/
|
|
||||||
export function shouldSkipLiteralValidation(value: unknown): boolean {
|
|
||||||
return isExpression(value) || containsExpression(value);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Extracts the expression content from a value
|
|
||||||
*
|
|
||||||
* If value is `={{ $json.value }}`, returns `$json.value`
|
|
||||||
* If value is `=$json.value`, returns `$json.value`
|
|
||||||
* If value is not an expression, returns the original value
|
|
||||||
*
|
|
||||||
* @param value - The value to extract from
|
|
||||||
* @returns The expression content or original value
|
|
||||||
*/
|
|
||||||
export function extractExpressionContent(value: string): string {
|
|
||||||
if (!isExpression(value)) {
|
|
||||||
return value;
|
|
||||||
}
|
|
||||||
|
|
||||||
const withoutPrefix = value.substring(1); // Remove =
|
|
||||||
|
|
||||||
// Check if it's wrapped in {{ }}
|
|
||||||
const match = withoutPrefix.match(/^\{\{(.+)\}\}$/s);
|
|
||||||
if (match) {
|
|
||||||
return match[1].trim();
|
|
||||||
}
|
|
||||||
|
|
||||||
return withoutPrefix;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Checks if a value is a mixed content expression
|
|
||||||
*
|
|
||||||
* Mixed content has both literal text and expressions:
|
|
||||||
* - `Hello {{ $json.name }}!`
|
|
||||||
* - `https://api.com/{{ $json.id }}/data`
|
|
||||||
*
|
|
||||||
* @param value - The value to check
|
|
||||||
* @returns true if the value has mixed content
|
|
||||||
*/
|
|
||||||
export function hasMixedContent(value: unknown): boolean {
|
|
||||||
// Type guard first to avoid calling containsExpression on non-strings
|
|
||||||
if (typeof value !== 'string') {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!containsExpression(value)) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
// If it's wrapped entirely in {{ }}, it's not mixed
|
|
||||||
const trimmed = value.trim();
|
|
||||||
if (trimmed.startsWith('={{') && trimmed.endsWith('}}')) {
|
|
||||||
// Check if there's only one pair of {{ }}
|
|
||||||
const count = (trimmed.match(/\{\{/g) || []).length;
|
|
||||||
if (count === 1) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
@@ -1,121 +0,0 @@
|
|||||||
/**
|
|
||||||
* Node Classification Utilities
|
|
||||||
*
|
|
||||||
* Provides shared classification logic for workflow nodes.
|
|
||||||
* Used by validators to consistently identify node types across the codebase.
|
|
||||||
*
|
|
||||||
* This module centralizes node type classification to ensure consistent behavior
|
|
||||||
* between WorkflowValidator and n8n-validation.ts, preventing bugs like sticky
|
|
||||||
* notes being incorrectly flagged as disconnected nodes.
|
|
||||||
*/
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Check if a node type is a sticky note (documentation-only node)
|
|
||||||
*
|
|
||||||
* Sticky notes are UI-only annotation nodes that:
|
|
||||||
* - Do not participate in workflow execution
|
|
||||||
* - Never have connections (by design)
|
|
||||||
* - Should be excluded from connection validation
|
|
||||||
* - Serve purely as visual documentation in the workflow canvas
|
|
||||||
*
|
|
||||||
* Example sticky note types:
|
|
||||||
* - 'n8n-nodes-base.stickyNote' (standard format)
|
|
||||||
* - 'nodes-base.stickyNote' (normalized format)
|
|
||||||
* - '@n8n/n8n-nodes-base.stickyNote' (scoped format)
|
|
||||||
*
|
|
||||||
* @param nodeType - The node type to check (e.g., 'n8n-nodes-base.stickyNote')
|
|
||||||
* @returns true if the node is a sticky note, false otherwise
|
|
||||||
*/
|
|
||||||
export function isStickyNote(nodeType: string): boolean {
|
|
||||||
const stickyNoteTypes = [
|
|
||||||
'n8n-nodes-base.stickyNote',
|
|
||||||
'nodes-base.stickyNote',
|
|
||||||
'@n8n/n8n-nodes-base.stickyNote'
|
|
||||||
];
|
|
||||||
return stickyNoteTypes.includes(nodeType);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Check if a node type is a trigger node
|
|
||||||
*
|
|
||||||
* Trigger nodes:
|
|
||||||
* - Start workflow execution
|
|
||||||
* - Only need outgoing connections (no incoming connections required)
|
|
||||||
* - Include webhooks, manual triggers, schedule triggers, etc.
|
|
||||||
* - Are the entry points for workflow execution
|
|
||||||
*
|
|
||||||
* Examples:
|
|
||||||
* - Webhooks: Listen for HTTP requests
|
|
||||||
* - Manual triggers: Started manually by user
|
|
||||||
* - Schedule/Cron triggers: Run on a schedule
|
|
||||||
*
|
|
||||||
* @param nodeType - The node type to check
|
|
||||||
* @returns true if the node is a trigger, false otherwise
|
|
||||||
*/
|
|
||||||
export function isTriggerNode(nodeType: string): boolean {
|
|
||||||
const triggerTypes = [
|
|
||||||
'n8n-nodes-base.webhook',
|
|
||||||
'n8n-nodes-base.webhookTrigger',
|
|
||||||
'n8n-nodes-base.manualTrigger',
|
|
||||||
'n8n-nodes-base.cronTrigger',
|
|
||||||
'n8n-nodes-base.scheduleTrigger'
|
|
||||||
];
|
|
||||||
return triggerTypes.includes(nodeType);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Check if a node type is non-executable (UI-only)
|
|
||||||
*
|
|
||||||
* Non-executable nodes:
|
|
||||||
* - Do not participate in workflow execution
|
|
||||||
* - Serve documentation/annotation purposes only
|
|
||||||
* - Should be excluded from all execution-related validation
|
|
||||||
* - Should be excluded from statistics like "total executable nodes"
|
|
||||||
* - Should be excluded from connection validation
|
|
||||||
*
|
|
||||||
* Currently includes: sticky notes
|
|
||||||
*
|
|
||||||
* Future: May include other annotation/comment nodes if n8n adds them
|
|
||||||
*
|
|
||||||
* @param nodeType - The node type to check
|
|
||||||
* @returns true if the node is non-executable, false otherwise
|
|
||||||
*/
|
|
||||||
export function isNonExecutableNode(nodeType: string): boolean {
|
|
||||||
return isStickyNote(nodeType);
|
|
||||||
// Future: Add other non-executable node types here
|
|
||||||
// Example: || isCommentNode(nodeType) || isAnnotationNode(nodeType)
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Check if a node type requires incoming connections
|
|
||||||
*
|
|
||||||
* Most nodes require at least one incoming connection to receive data,
|
|
||||||
* but there are two categories of exceptions:
|
|
||||||
*
|
|
||||||
* 1. Trigger nodes: Only need outgoing connections
|
|
||||||
* - They start workflow execution
|
|
||||||
* - They generate their own data
|
|
||||||
* - Examples: webhook, manualTrigger, scheduleTrigger
|
|
||||||
*
|
|
||||||
* 2. Non-executable nodes: Don't need any connections
|
|
||||||
* - They are UI-only annotations
|
|
||||||
* - They don't participate in execution
|
|
||||||
* - Examples: stickyNote
|
|
||||||
*
|
|
||||||
* @param nodeType - The node type to check
|
|
||||||
* @returns true if the node requires incoming connections, false otherwise
|
|
||||||
*/
|
|
||||||
export function requiresIncomingConnection(nodeType: string): boolean {
|
|
||||||
// Non-executable nodes don't need any connections
|
|
||||||
if (isNonExecutableNode(nodeType)) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Trigger nodes only need outgoing connections
|
|
||||||
if (isTriggerNode(nodeType)) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Regular nodes need incoming connections
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
@@ -205,20 +205,9 @@ describe.skipIf(!dbExists)('Database Content Validation', () => {
|
|||||||
|
|
||||||
it('MUST have FTS5 index properly ranked', () => {
|
it('MUST have FTS5 index properly ranked', () => {
|
||||||
const results = db.prepare(`
|
const results = db.prepare(`
|
||||||
SELECT
|
SELECT node_type, rank FROM nodes_fts
|
||||||
n.node_type,
|
|
||||||
rank
|
|
||||||
FROM nodes n
|
|
||||||
JOIN nodes_fts ON n.rowid = nodes_fts.rowid
|
|
||||||
WHERE nodes_fts MATCH 'webhook'
|
WHERE nodes_fts MATCH 'webhook'
|
||||||
ORDER BY
|
ORDER BY rank
|
||||||
CASE
|
|
||||||
WHEN LOWER(n.display_name) = LOWER('webhook') THEN 0
|
|
||||||
WHEN LOWER(n.display_name) LIKE LOWER('%webhook%') THEN 1
|
|
||||||
WHEN LOWER(n.node_type) LIKE LOWER('%webhook%') THEN 2
|
|
||||||
ELSE 3
|
|
||||||
END,
|
|
||||||
rank
|
|
||||||
LIMIT 5
|
LIMIT 5
|
||||||
`).all();
|
`).all();
|
||||||
|
|
||||||
@@ -226,7 +215,7 @@ describe.skipIf(!dbExists)('Database Content Validation', () => {
|
|||||||
'CRITICAL: FTS5 ranking not working. Search quality will be degraded.'
|
'CRITICAL: FTS5 ranking not working. Search quality will be degraded.'
|
||||||
).toBeGreaterThan(0);
|
).toBeGreaterThan(0);
|
||||||
|
|
||||||
// Exact match should be in top results (using production boosting logic with CASE-first ordering)
|
// Exact match should be in top results
|
||||||
const topNodes = results.slice(0, 3).map((r: any) => r.node_type);
|
const topNodes = results.slice(0, 3).map((r: any) => r.node_type);
|
||||||
expect(topNodes,
|
expect(topNodes,
|
||||||
'WARNING: Exact match "nodes-base.webhook" not in top 3 ranked results'
|
'WARNING: Exact match "nodes-base.webhook" not in top 3 ranked results'
|
||||||
|
|||||||
@@ -136,25 +136,14 @@ describe('Node FTS5 Search Integration Tests', () => {
|
|||||||
describe('FTS5 Search Quality', () => {
|
describe('FTS5 Search Quality', () => {
|
||||||
it('should rank exact matches higher', () => {
|
it('should rank exact matches higher', () => {
|
||||||
const results = db.prepare(`
|
const results = db.prepare(`
|
||||||
SELECT
|
SELECT node_type, rank FROM nodes_fts
|
||||||
n.node_type,
|
|
||||||
rank
|
|
||||||
FROM nodes n
|
|
||||||
JOIN nodes_fts ON n.rowid = nodes_fts.rowid
|
|
||||||
WHERE nodes_fts MATCH 'webhook'
|
WHERE nodes_fts MATCH 'webhook'
|
||||||
ORDER BY
|
ORDER BY rank
|
||||||
CASE
|
|
||||||
WHEN LOWER(n.display_name) = LOWER('webhook') THEN 0
|
|
||||||
WHEN LOWER(n.display_name) LIKE LOWER('%webhook%') THEN 1
|
|
||||||
WHEN LOWER(n.node_type) LIKE LOWER('%webhook%') THEN 2
|
|
||||||
ELSE 3
|
|
||||||
END,
|
|
||||||
rank
|
|
||||||
LIMIT 10
|
LIMIT 10
|
||||||
`).all();
|
`).all();
|
||||||
|
|
||||||
expect(results.length).toBeGreaterThan(0);
|
expect(results.length).toBeGreaterThan(0);
|
||||||
// Exact match should be in top results (using production boosting logic with CASE-first ordering)
|
// Exact match should be in top results
|
||||||
const topResults = results.slice(0, 3).map((r: any) => r.node_type);
|
const topResults = results.slice(0, 3).map((r: any) => r.node_type);
|
||||||
expect(topResults).toContain('nodes-base.webhook');
|
expect(topResults).toContain('nodes-base.webhook');
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -1,532 +0,0 @@
|
|||||||
import { describe, test, expect } from 'vitest';
|
|
||||||
import { validateWorkflowStructure } from '@/services/n8n-validation';
|
|
||||||
import type { Workflow } from '@/types/n8n-api';
|
|
||||||
|
|
||||||
describe('n8n-validation - Sticky Notes Bug Fix', () => {
|
|
||||||
describe('sticky notes should be excluded from disconnected nodes validation', () => {
|
|
||||||
test('should allow workflow with sticky notes and connected functional nodes', () => {
|
|
||||||
const workflow: Partial<Workflow> = {
|
|
||||||
name: 'Test Workflow',
|
|
||||||
nodes: [
|
|
||||||
{
|
|
||||||
id: '1',
|
|
||||||
name: 'Webhook',
|
|
||||||
type: 'n8n-nodes-base.webhook',
|
|
||||||
typeVersion: 1,
|
|
||||||
position: [250, 300],
|
|
||||||
parameters: { path: '/test' }
|
|
||||||
},
|
|
||||||
{
|
|
||||||
id: '2',
|
|
||||||
name: 'HTTP Request',
|
|
||||||
type: 'n8n-nodes-base.httpRequest',
|
|
||||||
typeVersion: 3,
|
|
||||||
position: [450, 300],
|
|
||||||
parameters: {}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
id: 'sticky1',
|
|
||||||
name: 'Documentation Note',
|
|
||||||
type: 'n8n-nodes-base.stickyNote',
|
|
||||||
typeVersion: 1,
|
|
||||||
position: [250, 100],
|
|
||||||
parameters: { content: 'This is a documentation note' }
|
|
||||||
}
|
|
||||||
],
|
|
||||||
connections: {
|
|
||||||
'Webhook': {
|
|
||||||
main: [[{ node: 'HTTP Request', type: 'main', index: 0 }]]
|
|
||||||
}
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
const errors = validateWorkflowStructure(workflow);
|
|
||||||
|
|
||||||
// Should have no errors - sticky note should be ignored
|
|
||||||
expect(errors).toEqual([]);
|
|
||||||
});
|
|
||||||
|
|
||||||
test('should handle multiple sticky notes without errors', () => {
|
|
||||||
const workflow: Partial<Workflow> = {
|
|
||||||
name: 'Documented Workflow',
|
|
||||||
nodes: [
|
|
||||||
{
|
|
||||||
id: '1',
|
|
||||||
name: 'Webhook',
|
|
||||||
type: 'n8n-nodes-base.webhook',
|
|
||||||
typeVersion: 1,
|
|
||||||
position: [250, 300],
|
|
||||||
parameters: { path: '/test' }
|
|
||||||
},
|
|
||||||
{
|
|
||||||
id: '2',
|
|
||||||
name: 'Process',
|
|
||||||
type: 'n8n-nodes-base.set',
|
|
||||||
typeVersion: 3,
|
|
||||||
position: [450, 300],
|
|
||||||
parameters: {}
|
|
||||||
},
|
|
||||||
// 10 sticky notes for documentation
|
|
||||||
...Array.from({ length: 10 }, (_, i) => ({
|
|
||||||
id: `sticky${i}`,
|
|
||||||
name: `📝 Note ${i}`,
|
|
||||||
type: 'n8n-nodes-base.stickyNote',
|
|
||||||
typeVersion: 1,
|
|
||||||
position: [100 + i * 50, 100] as [number, number],
|
|
||||||
parameters: { content: `Documentation note ${i}` }
|
|
||||||
}))
|
|
||||||
],
|
|
||||||
connections: {
|
|
||||||
'Webhook': {
|
|
||||||
main: [[{ node: 'Process', type: 'main', index: 0 }]]
|
|
||||||
}
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
const errors = validateWorkflowStructure(workflow);
|
|
||||||
expect(errors).toEqual([]);
|
|
||||||
});
|
|
||||||
|
|
||||||
test('should handle all sticky note type variations', () => {
|
|
||||||
const stickyTypes = [
|
|
||||||
'n8n-nodes-base.stickyNote',
|
|
||||||
'nodes-base.stickyNote',
|
|
||||||
'@n8n/n8n-nodes-base.stickyNote'
|
|
||||||
];
|
|
||||||
|
|
||||||
stickyTypes.forEach((stickyType, index) => {
|
|
||||||
const workflow: Partial<Workflow> = {
|
|
||||||
name: 'Test Workflow',
|
|
||||||
nodes: [
|
|
||||||
{
|
|
||||||
id: '1',
|
|
||||||
name: 'Webhook',
|
|
||||||
type: 'n8n-nodes-base.webhook',
|
|
||||||
typeVersion: 1,
|
|
||||||
position: [250, 300],
|
|
||||||
parameters: { path: '/test' }
|
|
||||||
},
|
|
||||||
{
|
|
||||||
id: `sticky${index}`,
|
|
||||||
name: `Note ${index}`,
|
|
||||||
type: stickyType,
|
|
||||||
typeVersion: 1,
|
|
||||||
position: [250, 100],
|
|
||||||
parameters: { content: `Note ${index}` }
|
|
||||||
}
|
|
||||||
],
|
|
||||||
connections: {}
|
|
||||||
};
|
|
||||||
|
|
||||||
const errors = validateWorkflowStructure(workflow);
|
|
||||||
|
|
||||||
// Sticky note should be ignored regardless of type variation
|
|
||||||
expect(errors.every(e => !e.includes(`Note ${index}`))).toBe(true);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
test('should handle complex workflow with multiple sticky notes (real-world scenario)', () => {
|
|
||||||
// Simulates workflow like "POST /auth/login" with 4 sticky notes
|
|
||||||
const workflow: Partial<Workflow> = {
|
|
||||||
name: 'POST /auth/login',
|
|
||||||
nodes: [
|
|
||||||
{
|
|
||||||
id: 'webhook1',
|
|
||||||
name: 'Webhook Trigger',
|
|
||||||
type: 'n8n-nodes-base.webhook',
|
|
||||||
typeVersion: 1,
|
|
||||||
position: [250, 300],
|
|
||||||
parameters: { path: '/auth/login', httpMethod: 'POST' }
|
|
||||||
},
|
|
||||||
{
|
|
||||||
id: 'http1',
|
|
||||||
name: 'Authenticate',
|
|
||||||
type: 'n8n-nodes-base.httpRequest',
|
|
||||||
typeVersion: 3,
|
|
||||||
position: [450, 300],
|
|
||||||
parameters: {}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
id: 'respond1',
|
|
||||||
name: 'Return Success',
|
|
||||||
type: 'n8n-nodes-base.respondToWebhook',
|
|
||||||
typeVersion: 1,
|
|
||||||
position: [650, 250],
|
|
||||||
parameters: {}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
id: 'respond2',
|
|
||||||
name: 'Return Error',
|
|
||||||
type: 'n8n-nodes-base.respondToWebhook',
|
|
||||||
typeVersion: 1,
|
|
||||||
position: [650, 350],
|
|
||||||
parameters: {}
|
|
||||||
},
|
|
||||||
// 4 sticky notes for documentation
|
|
||||||
{
|
|
||||||
id: 'sticky1',
|
|
||||||
name: '📝 Webhook Trigger',
|
|
||||||
type: 'n8n-nodes-base.stickyNote',
|
|
||||||
typeVersion: 1,
|
|
||||||
position: [250, 150],
|
|
||||||
parameters: { content: 'Receives login request' }
|
|
||||||
},
|
|
||||||
{
|
|
||||||
id: 'sticky2',
|
|
||||||
name: '📝 Authenticate with Supabase',
|
|
||||||
type: 'n8n-nodes-base.stickyNote',
|
|
||||||
typeVersion: 1,
|
|
||||||
position: [450, 150],
|
|
||||||
parameters: { content: 'Validates credentials' }
|
|
||||||
},
|
|
||||||
{
|
|
||||||
id: 'sticky3',
|
|
||||||
name: '📝 Return Tokens',
|
|
||||||
type: 'n8n-nodes-base.stickyNote',
|
|
||||||
typeVersion: 1,
|
|
||||||
position: [650, 150],
|
|
||||||
parameters: { content: 'Returns access and refresh tokens' }
|
|
||||||
},
|
|
||||||
{
|
|
||||||
id: 'sticky4',
|
|
||||||
name: '📝 Return Error',
|
|
||||||
type: 'n8n-nodes-base.stickyNote',
|
|
||||||
typeVersion: 1,
|
|
||||||
position: [650, 450],
|
|
||||||
parameters: { content: 'Returns error message' }
|
|
||||||
}
|
|
||||||
],
|
|
||||||
connections: {
|
|
||||||
'Webhook Trigger': {
|
|
||||||
main: [[{ node: 'Authenticate', type: 'main', index: 0 }]]
|
|
||||||
},
|
|
||||||
'Authenticate': {
|
|
||||||
main: [
|
|
||||||
[{ node: 'Return Success', type: 'main', index: 0 }],
|
|
||||||
[{ node: 'Return Error', type: 'main', index: 0 }]
|
|
||||||
]
|
|
||||||
}
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
const errors = validateWorkflowStructure(workflow);
|
|
||||||
|
|
||||||
// Should have no errors - all sticky notes should be ignored
|
|
||||||
expect(errors).toEqual([]);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
describe('validation should still detect truly disconnected functional nodes', () => {
|
|
||||||
test('should detect disconnected HTTP node but ignore sticky note', () => {
|
|
||||||
const workflow: Partial<Workflow> = {
|
|
||||||
name: 'Test Workflow',
|
|
||||||
nodes: [
|
|
||||||
{
|
|
||||||
id: '1',
|
|
||||||
name: 'Webhook',
|
|
||||||
type: 'n8n-nodes-base.webhook',
|
|
||||||
typeVersion: 1,
|
|
||||||
position: [250, 300],
|
|
||||||
parameters: { path: '/test' }
|
|
||||||
},
|
|
||||||
{
|
|
||||||
id: '2',
|
|
||||||
name: 'Disconnected HTTP',
|
|
||||||
type: 'n8n-nodes-base.httpRequest',
|
|
||||||
typeVersion: 3,
|
|
||||||
position: [450, 300],
|
|
||||||
parameters: {}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
id: 'sticky1',
|
|
||||||
name: 'Sticky Note',
|
|
||||||
type: 'n8n-nodes-base.stickyNote',
|
|
||||||
typeVersion: 1,
|
|
||||||
position: [250, 100],
|
|
||||||
parameters: { content: 'Note' }
|
|
||||||
}
|
|
||||||
],
|
|
||||||
connections: {} // No connections
|
|
||||||
};
|
|
||||||
|
|
||||||
const errors = validateWorkflowStructure(workflow);
|
|
||||||
|
|
||||||
// Should error on HTTP node, but NOT on sticky note
|
|
||||||
expect(errors.length).toBeGreaterThan(0);
|
|
||||||
const disconnectedError = errors.find(e => e.includes('Disconnected'));
|
|
||||||
expect(disconnectedError).toBeDefined();
|
|
||||||
expect(disconnectedError).toContain('Disconnected HTTP');
|
|
||||||
expect(disconnectedError).not.toContain('Sticky Note');
|
|
||||||
});
|
|
||||||
|
|
||||||
test('should detect multiple disconnected functional nodes but ignore sticky notes', () => {
|
|
||||||
const workflow: Partial<Workflow> = {
|
|
||||||
name: 'Test Workflow',
|
|
||||||
nodes: [
|
|
||||||
{
|
|
||||||
id: '1',
|
|
||||||
name: 'Webhook',
|
|
||||||
type: 'n8n-nodes-base.webhook',
|
|
||||||
typeVersion: 1,
|
|
||||||
position: [250, 300],
|
|
||||||
parameters: { path: '/test' }
|
|
||||||
},
|
|
||||||
{
|
|
||||||
id: '2',
|
|
||||||
name: 'Disconnected HTTP',
|
|
||||||
type: 'n8n-nodes-base.httpRequest',
|
|
||||||
typeVersion: 3,
|
|
||||||
position: [450, 300],
|
|
||||||
parameters: {}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
id: '3',
|
|
||||||
name: 'Disconnected Set',
|
|
||||||
type: 'n8n-nodes-base.set',
|
|
||||||
typeVersion: 3,
|
|
||||||
position: [650, 300],
|
|
||||||
parameters: {}
|
|
||||||
},
|
|
||||||
// Multiple sticky notes that should be ignored
|
|
||||||
{
|
|
||||||
id: 'sticky1',
|
|
||||||
name: 'Note 1',
|
|
||||||
type: 'n8n-nodes-base.stickyNote',
|
|
||||||
typeVersion: 1,
|
|
||||||
position: [250, 100],
|
|
||||||
parameters: { content: 'Note 1' }
|
|
||||||
},
|
|
||||||
{
|
|
||||||
id: 'sticky2',
|
|
||||||
name: 'Note 2',
|
|
||||||
type: 'n8n-nodes-base.stickyNote',
|
|
||||||
typeVersion: 1,
|
|
||||||
position: [450, 100],
|
|
||||||
parameters: { content: 'Note 2' }
|
|
||||||
}
|
|
||||||
],
|
|
||||||
connections: {} // No connections
|
|
||||||
};
|
|
||||||
|
|
||||||
const errors = validateWorkflowStructure(workflow);
|
|
||||||
|
|
||||||
// Should error because there are no connections
|
|
||||||
// When there are NO connections, validation shows "Multi-node workflow has no connections"
|
|
||||||
// This is the expected behavior - it suggests connecting any two executable nodes
|
|
||||||
expect(errors.length).toBeGreaterThan(0);
|
|
||||||
const connectionError = errors.find(e => e.includes('no connections') || e.includes('Disconnected'));
|
|
||||||
expect(connectionError).toBeDefined();
|
|
||||||
// Error should NOT mention sticky notes
|
|
||||||
expect(connectionError).not.toContain('Note 1');
|
|
||||||
expect(connectionError).not.toContain('Note 2');
|
|
||||||
});
|
|
||||||
|
|
||||||
test('should allow sticky notes but still validate functional node connections', () => {
|
|
||||||
const workflow: Partial<Workflow> = {
|
|
||||||
name: 'Test Workflow',
|
|
||||||
nodes: [
|
|
||||||
{
|
|
||||||
id: '1',
|
|
||||||
name: 'Webhook',
|
|
||||||
type: 'n8n-nodes-base.webhook',
|
|
||||||
typeVersion: 1,
|
|
||||||
position: [250, 300],
|
|
||||||
parameters: { path: '/test' }
|
|
||||||
},
|
|
||||||
{
|
|
||||||
id: '2',
|
|
||||||
name: 'Connected HTTP',
|
|
||||||
type: 'n8n-nodes-base.httpRequest',
|
|
||||||
typeVersion: 3,
|
|
||||||
position: [450, 300],
|
|
||||||
parameters: {}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
id: '3',
|
|
||||||
name: 'Disconnected Set',
|
|
||||||
type: 'n8n-nodes-base.set',
|
|
||||||
typeVersion: 3,
|
|
||||||
position: [650, 300],
|
|
||||||
parameters: {}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
id: 'sticky1',
|
|
||||||
name: 'Sticky Note',
|
|
||||||
type: 'n8n-nodes-base.stickyNote',
|
|
||||||
typeVersion: 1,
|
|
||||||
position: [250, 100],
|
|
||||||
parameters: { content: 'Note' }
|
|
||||||
}
|
|
||||||
],
|
|
||||||
connections: {
|
|
||||||
'Webhook': {
|
|
||||||
main: [[{ node: 'Connected HTTP', type: 'main', index: 0 }]]
|
|
||||||
}
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
const errors = validateWorkflowStructure(workflow);
|
|
||||||
|
|
||||||
// Should error only on disconnected Set node
|
|
||||||
expect(errors.length).toBeGreaterThan(0);
|
|
||||||
const disconnectedError = errors.find(e => e.includes('Disconnected'));
|
|
||||||
expect(disconnectedError).toBeDefined();
|
|
||||||
expect(disconnectedError).toContain('Disconnected Set');
|
|
||||||
expect(disconnectedError).not.toContain('Connected HTTP');
|
|
||||||
expect(disconnectedError).not.toContain('Sticky Note');
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
describe('regression tests - ensure sticky notes work like in n8n UI', () => {
|
|
||||||
test('single webhook with sticky notes should be valid (matches n8n UI behavior)', () => {
|
|
||||||
const workflow: Partial<Workflow> = {
|
|
||||||
name: 'Webhook Only with Notes',
|
|
||||||
nodes: [
|
|
||||||
{
|
|
||||||
id: '1',
|
|
||||||
name: 'Webhook',
|
|
||||||
type: 'n8n-nodes-base.webhook',
|
|
||||||
typeVersion: 1,
|
|
||||||
position: [250, 300],
|
|
||||||
parameters: { path: '/test' }
|
|
||||||
},
|
|
||||||
{
|
|
||||||
id: 'sticky1',
|
|
||||||
name: 'Usage Instructions',
|
|
||||||
type: 'n8n-nodes-base.stickyNote',
|
|
||||||
typeVersion: 1,
|
|
||||||
position: [250, 100],
|
|
||||||
parameters: { content: 'Call this webhook to trigger the workflow' }
|
|
||||||
}
|
|
||||||
],
|
|
||||||
connections: {}
|
|
||||||
};
|
|
||||||
|
|
||||||
const errors = validateWorkflowStructure(workflow);
|
|
||||||
|
|
||||||
// Webhook-only workflows are valid in n8n
|
|
||||||
// Sticky notes should not affect this
|
|
||||||
expect(errors).toEqual([]);
|
|
||||||
});
|
|
||||||
|
|
||||||
test('workflow with only sticky notes should be invalid (no executable nodes)', () => {
|
|
||||||
const workflow: Partial<Workflow> = {
|
|
||||||
name: 'Only Notes',
|
|
||||||
nodes: [
|
|
||||||
{
|
|
||||||
id: 'sticky1',
|
|
||||||
name: 'Note 1',
|
|
||||||
type: 'n8n-nodes-base.stickyNote',
|
|
||||||
typeVersion: 1,
|
|
||||||
position: [250, 100],
|
|
||||||
parameters: { content: 'Note 1' }
|
|
||||||
},
|
|
||||||
{
|
|
||||||
id: 'sticky2',
|
|
||||||
name: 'Note 2',
|
|
||||||
type: 'n8n-nodes-base.stickyNote',
|
|
||||||
typeVersion: 1,
|
|
||||||
position: [450, 100],
|
|
||||||
parameters: { content: 'Note 2' }
|
|
||||||
}
|
|
||||||
],
|
|
||||||
connections: {}
|
|
||||||
};
|
|
||||||
|
|
||||||
const errors = validateWorkflowStructure(workflow);
|
|
||||||
|
|
||||||
// Should fail because there are no executable nodes
|
|
||||||
expect(errors.length).toBeGreaterThan(0);
|
|
||||||
expect(errors.some(e => e.includes('at least one executable node'))).toBe(true);
|
|
||||||
});
|
|
||||||
|
|
||||||
test('complex production workflow structure should validate correctly', () => {
|
|
||||||
// Tests a realistic production workflow structure
|
|
||||||
const workflow: Partial<Workflow> = {
|
|
||||||
name: 'Production API Endpoint',
|
|
||||||
nodes: [
|
|
||||||
// Functional nodes
|
|
||||||
{
|
|
||||||
id: 'webhook1',
|
|
||||||
name: 'API Webhook',
|
|
||||||
type: 'n8n-nodes-base.webhook',
|
|
||||||
typeVersion: 1,
|
|
||||||
position: [250, 300],
|
|
||||||
parameters: { path: '/api/endpoint' }
|
|
||||||
},
|
|
||||||
{
|
|
||||||
id: 'validate1',
|
|
||||||
name: 'Validate Input',
|
|
||||||
type: 'n8n-nodes-base.code',
|
|
||||||
typeVersion: 2,
|
|
||||||
position: [450, 300],
|
|
||||||
parameters: {}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
id: 'branch1',
|
|
||||||
name: 'Check Valid',
|
|
||||||
type: 'n8n-nodes-base.if',
|
|
||||||
typeVersion: 2,
|
|
||||||
position: [650, 300],
|
|
||||||
parameters: {}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
id: 'process1',
|
|
||||||
name: 'Process Request',
|
|
||||||
type: 'n8n-nodes-base.httpRequest',
|
|
||||||
typeVersion: 3,
|
|
||||||
position: [850, 250],
|
|
||||||
parameters: {}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
id: 'success1',
|
|
||||||
name: 'Return Success',
|
|
||||||
type: 'n8n-nodes-base.respondToWebhook',
|
|
||||||
typeVersion: 1,
|
|
||||||
position: [1050, 250],
|
|
||||||
parameters: {}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
id: 'error1',
|
|
||||||
name: 'Return Error',
|
|
||||||
type: 'n8n-nodes-base.respondToWebhook',
|
|
||||||
typeVersion: 1,
|
|
||||||
position: [850, 350],
|
|
||||||
parameters: {}
|
|
||||||
},
|
|
||||||
// Documentation sticky notes (11 notes like in real workflow)
|
|
||||||
...Array.from({ length: 11 }, (_, i) => ({
|
|
||||||
id: `sticky${i}`,
|
|
||||||
name: `📝 Documentation ${i}`,
|
|
||||||
type: 'n8n-nodes-base.stickyNote',
|
|
||||||
typeVersion: 1,
|
|
||||||
position: [250 + i * 100, 100] as [number, number],
|
|
||||||
parameters: { content: `Documentation section ${i}` }
|
|
||||||
}))
|
|
||||||
],
|
|
||||||
connections: {
|
|
||||||
'API Webhook': {
|
|
||||||
main: [[{ node: 'Validate Input', type: 'main', index: 0 }]]
|
|
||||||
},
|
|
||||||
'Validate Input': {
|
|
||||||
main: [[{ node: 'Check Valid', type: 'main', index: 0 }]]
|
|
||||||
},
|
|
||||||
'Check Valid': {
|
|
||||||
main: [
|
|
||||||
[{ node: 'Process Request', type: 'main', index: 0 }],
|
|
||||||
[{ node: 'Return Error', type: 'main', index: 0 }]
|
|
||||||
]
|
|
||||||
},
|
|
||||||
'Process Request': {
|
|
||||||
main: [[{ node: 'Return Success', type: 'main', index: 0 }]]
|
|
||||||
}
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
const errors = validateWorkflowStructure(workflow);
|
|
||||||
|
|
||||||
// Should be valid - all functional nodes connected, sticky notes ignored
|
|
||||||
expect(errors).toEqual([]);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
});
|
|
||||||
@@ -1610,12 +1610,7 @@ describe('NodeSpecificValidators', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
describe('response mode validation', () => {
|
describe('response mode validation', () => {
|
||||||
// NOTE: responseNode mode validation was moved to workflow-validator.ts in Phase 5
|
it('should error on responseNode without error handling', () => {
|
||||||
// because it requires access to node-level onError property, not just config/parameters.
|
|
||||||
// See workflow-validator.ts checkWebhookErrorHandling() method for the actual implementation.
|
|
||||||
// The validation cannot be performed at the node-specific-validator level.
|
|
||||||
|
|
||||||
it.skip('should error on responseNode without error handling - MOVED TO WORKFLOW VALIDATOR', () => {
|
|
||||||
context.config = {
|
context.config = {
|
||||||
path: 'my-webhook',
|
path: 'my-webhook',
|
||||||
httpMethod: 'POST',
|
httpMethod: 'POST',
|
||||||
@@ -1632,7 +1627,7 @@ describe('NodeSpecificValidators', () => {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
it.skip('should not error on responseNode with proper error handling - MOVED TO WORKFLOW VALIDATOR', () => {
|
it('should not error on responseNode with proper error handling', () => {
|
||||||
context.config = {
|
context.config = {
|
||||||
path: 'my-webhook',
|
path: 'my-webhook',
|
||||||
httpMethod: 'POST',
|
httpMethod: 'POST',
|
||||||
|
|||||||
@@ -1,414 +0,0 @@
|
|||||||
/**
|
|
||||||
* Tests for Expression Utilities
|
|
||||||
*
|
|
||||||
* Comprehensive test suite for n8n expression detection utilities
|
|
||||||
* that help validators understand when to skip literal validation
|
|
||||||
*/
|
|
||||||
|
|
||||||
import { describe, it, expect } from 'vitest';
|
|
||||||
import {
|
|
||||||
isExpression,
|
|
||||||
containsExpression,
|
|
||||||
shouldSkipLiteralValidation,
|
|
||||||
extractExpressionContent,
|
|
||||||
hasMixedContent
|
|
||||||
} from '../../../src/utils/expression-utils';
|
|
||||||
|
|
||||||
describe('Expression Utilities', () => {
|
|
||||||
describe('isExpression', () => {
|
|
||||||
describe('Valid expressions', () => {
|
|
||||||
it('should detect expression with = prefix and {{ }}', () => {
|
|
||||||
expect(isExpression('={{ $json.value }}')).toBe(true);
|
|
||||||
});
|
|
||||||
|
|
||||||
it('should detect expression with = prefix only', () => {
|
|
||||||
expect(isExpression('=$json.value')).toBe(true);
|
|
||||||
});
|
|
||||||
|
|
||||||
it('should detect mixed content expression', () => {
|
|
||||||
expect(isExpression('=https://api.com/{{ $json.id }}/data')).toBe(true);
|
|
||||||
});
|
|
||||||
|
|
||||||
it('should detect expression with complex content', () => {
|
|
||||||
expect(isExpression('={{ $json.items.map(item => item.id) }}')).toBe(true);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
describe('Non-expressions', () => {
|
|
||||||
it('should return false for plain strings', () => {
|
|
||||||
expect(isExpression('plain text')).toBe(false);
|
|
||||||
});
|
|
||||||
|
|
||||||
it('should return false for URLs without = prefix', () => {
|
|
||||||
expect(isExpression('https://api.example.com')).toBe(false);
|
|
||||||
});
|
|
||||||
|
|
||||||
it('should return false for {{ }} without = prefix', () => {
|
|
||||||
expect(isExpression('{{ $json.value }}')).toBe(false);
|
|
||||||
});
|
|
||||||
|
|
||||||
it('should return false for empty string', () => {
|
|
||||||
expect(isExpression('')).toBe(false);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
describe('Edge cases', () => {
|
|
||||||
it('should return false for null', () => {
|
|
||||||
expect(isExpression(null)).toBe(false);
|
|
||||||
});
|
|
||||||
|
|
||||||
it('should return false for undefined', () => {
|
|
||||||
expect(isExpression(undefined)).toBe(false);
|
|
||||||
});
|
|
||||||
|
|
||||||
it('should return false for number', () => {
|
|
||||||
expect(isExpression(123)).toBe(false);
|
|
||||||
});
|
|
||||||
|
|
||||||
it('should return false for object', () => {
|
|
||||||
expect(isExpression({})).toBe(false);
|
|
||||||
});
|
|
||||||
|
|
||||||
it('should return false for array', () => {
|
|
||||||
expect(isExpression([])).toBe(false);
|
|
||||||
});
|
|
||||||
|
|
||||||
it('should return false for boolean', () => {
|
|
||||||
expect(isExpression(true)).toBe(false);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
describe('Type narrowing', () => {
|
|
||||||
it('should narrow type to string when true', () => {
|
|
||||||
const value: unknown = '=$json.value';
|
|
||||||
if (isExpression(value)) {
|
|
||||||
// This should compile because isExpression is a type predicate
|
|
||||||
const length: number = value.length;
|
|
||||||
expect(length).toBeGreaterThan(0);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
describe('containsExpression', () => {
|
|
||||||
describe('Valid expression markers', () => {
|
|
||||||
it('should detect {{ }} markers', () => {
|
|
||||||
expect(containsExpression('{{ $json.value }}')).toBe(true);
|
|
||||||
});
|
|
||||||
|
|
||||||
it('should detect expression markers in mixed content', () => {
|
|
||||||
expect(containsExpression('Hello {{ $json.name }}!')).toBe(true);
|
|
||||||
});
|
|
||||||
|
|
||||||
it('should detect multiple expression markers', () => {
|
|
||||||
expect(containsExpression('{{ $json.first }} and {{ $json.second }}')).toBe(true);
|
|
||||||
});
|
|
||||||
|
|
||||||
it('should detect expression with = prefix', () => {
|
|
||||||
expect(containsExpression('={{ $json.value }}')).toBe(true);
|
|
||||||
});
|
|
||||||
|
|
||||||
it('should detect expressions with newlines', () => {
|
|
||||||
expect(containsExpression('{{ $json.items\n .map(item => item.id) }}')).toBe(true);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
describe('Non-expressions', () => {
|
|
||||||
it('should return false for plain strings', () => {
|
|
||||||
expect(containsExpression('plain text')).toBe(false);
|
|
||||||
});
|
|
||||||
|
|
||||||
it('should return false for = prefix without {{ }}', () => {
|
|
||||||
expect(containsExpression('=$json.value')).toBe(false);
|
|
||||||
});
|
|
||||||
|
|
||||||
it('should return false for single braces', () => {
|
|
||||||
expect(containsExpression('{ value }')).toBe(false);
|
|
||||||
});
|
|
||||||
|
|
||||||
it('should return false for empty string', () => {
|
|
||||||
expect(containsExpression('')).toBe(false);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
describe('Edge cases', () => {
|
|
||||||
it('should return false for null', () => {
|
|
||||||
expect(containsExpression(null)).toBe(false);
|
|
||||||
});
|
|
||||||
|
|
||||||
it('should return false for undefined', () => {
|
|
||||||
expect(containsExpression(undefined)).toBe(false);
|
|
||||||
});
|
|
||||||
|
|
||||||
it('should return false for number', () => {
|
|
||||||
expect(containsExpression(123)).toBe(false);
|
|
||||||
});
|
|
||||||
|
|
||||||
it('should return false for object', () => {
|
|
||||||
expect(containsExpression({})).toBe(false);
|
|
||||||
});
|
|
||||||
|
|
||||||
it('should return false for array', () => {
|
|
||||||
expect(containsExpression([])).toBe(false);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
describe('shouldSkipLiteralValidation', () => {
|
|
||||||
describe('Should skip validation', () => {
|
|
||||||
it('should skip for expression with = prefix and {{ }}', () => {
|
|
||||||
expect(shouldSkipLiteralValidation('={{ $json.value }}')).toBe(true);
|
|
||||||
});
|
|
||||||
|
|
||||||
it('should skip for expression with = prefix only', () => {
|
|
||||||
expect(shouldSkipLiteralValidation('=$json.value')).toBe(true);
|
|
||||||
});
|
|
||||||
|
|
||||||
it('should skip for {{ }} without = prefix', () => {
|
|
||||||
expect(shouldSkipLiteralValidation('{{ $json.value }}')).toBe(true);
|
|
||||||
});
|
|
||||||
|
|
||||||
it('should skip for mixed content with expressions', () => {
|
|
||||||
expect(shouldSkipLiteralValidation('https://api.com/{{ $json.id }}/data')).toBe(true);
|
|
||||||
});
|
|
||||||
|
|
||||||
it('should skip for expression URL', () => {
|
|
||||||
expect(shouldSkipLiteralValidation('={{ $json.baseUrl }}/api')).toBe(true);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
describe('Should not skip validation', () => {
|
|
||||||
it('should validate plain strings', () => {
|
|
||||||
expect(shouldSkipLiteralValidation('plain text')).toBe(false);
|
|
||||||
});
|
|
||||||
|
|
||||||
it('should validate literal URLs', () => {
|
|
||||||
expect(shouldSkipLiteralValidation('https://api.example.com')).toBe(false);
|
|
||||||
});
|
|
||||||
|
|
||||||
it('should validate JSON strings', () => {
|
|
||||||
expect(shouldSkipLiteralValidation('{"key": "value"}')).toBe(false);
|
|
||||||
});
|
|
||||||
|
|
||||||
it('should validate numbers', () => {
|
|
||||||
expect(shouldSkipLiteralValidation(123)).toBe(false);
|
|
||||||
});
|
|
||||||
|
|
||||||
it('should validate null', () => {
|
|
||||||
expect(shouldSkipLiteralValidation(null)).toBe(false);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
describe('Real-world use cases', () => {
|
|
||||||
it('should skip validation for expression-based URLs', () => {
|
|
||||||
const url = '={{ $json.protocol }}://{{ $json.domain }}/api';
|
|
||||||
expect(shouldSkipLiteralValidation(url)).toBe(true);
|
|
||||||
});
|
|
||||||
|
|
||||||
it('should skip validation for expression-based JSON', () => {
|
|
||||||
const json = '={{ { key: $json.value } }}';
|
|
||||||
expect(shouldSkipLiteralValidation(json)).toBe(true);
|
|
||||||
});
|
|
||||||
|
|
||||||
it('should not skip validation for literal URLs', () => {
|
|
||||||
const url = 'https://api.example.com/endpoint';
|
|
||||||
expect(shouldSkipLiteralValidation(url)).toBe(false);
|
|
||||||
});
|
|
||||||
|
|
||||||
it('should not skip validation for literal JSON', () => {
|
|
||||||
const json = '{"userId": 123, "name": "test"}';
|
|
||||||
expect(shouldSkipLiteralValidation(json)).toBe(false);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
describe('extractExpressionContent', () => {
|
|
||||||
describe('Expression with = prefix and {{ }}', () => {
|
|
||||||
it('should extract content from ={{ }}', () => {
|
|
||||||
expect(extractExpressionContent('={{ $json.value }}')).toBe('$json.value');
|
|
||||||
});
|
|
||||||
|
|
||||||
it('should extract complex expression', () => {
|
|
||||||
expect(extractExpressionContent('={{ $json.items.map(i => i.id) }}')).toBe('$json.items.map(i => i.id)');
|
|
||||||
});
|
|
||||||
|
|
||||||
it('should trim whitespace', () => {
|
|
||||||
expect(extractExpressionContent('={{ $json.value }}')).toBe('$json.value');
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
describe('Expression with = prefix only', () => {
|
|
||||||
it('should extract content from = prefix', () => {
|
|
||||||
expect(extractExpressionContent('=$json.value')).toBe('$json.value');
|
|
||||||
});
|
|
||||||
|
|
||||||
it('should handle complex expressions without {{ }}', () => {
|
|
||||||
expect(extractExpressionContent('=$json.items[0].name')).toBe('$json.items[0].name');
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
describe('Non-expressions', () => {
|
|
||||||
it('should return original value for plain strings', () => {
|
|
||||||
expect(extractExpressionContent('plain text')).toBe('plain text');
|
|
||||||
});
|
|
||||||
|
|
||||||
it('should return original value for {{ }} without = prefix', () => {
|
|
||||||
expect(extractExpressionContent('{{ $json.value }}')).toBe('{{ $json.value }}');
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
describe('Edge cases', () => {
|
|
||||||
it('should handle empty expression', () => {
|
|
||||||
expect(extractExpressionContent('=')).toBe('');
|
|
||||||
});
|
|
||||||
|
|
||||||
it('should handle expression with only {{ }}', () => {
|
|
||||||
// Empty braces don't match the regex pattern, returns as-is
|
|
||||||
expect(extractExpressionContent('={{}}')).toBe('{{}}');
|
|
||||||
});
|
|
||||||
|
|
||||||
it('should handle nested braces (not valid but should not crash)', () => {
|
|
||||||
// The regex extracts content between outermost {{ }}
|
|
||||||
expect(extractExpressionContent('={{ {{ value }} }}')).toBe('{{ value }}');
|
|
||||||
});
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
describe('hasMixedContent', () => {
|
|
||||||
describe('Mixed content cases', () => {
|
|
||||||
it('should detect mixed content with text and expression', () => {
|
|
||||||
expect(hasMixedContent('Hello {{ $json.name }}!')).toBe(true);
|
|
||||||
});
|
|
||||||
|
|
||||||
it('should detect URL with expression segments', () => {
|
|
||||||
expect(hasMixedContent('https://api.com/{{ $json.id }}/data')).toBe(true);
|
|
||||||
});
|
|
||||||
|
|
||||||
it('should detect multiple expressions in text', () => {
|
|
||||||
expect(hasMixedContent('{{ $json.first }} and {{ $json.second }}')).toBe(true);
|
|
||||||
});
|
|
||||||
|
|
||||||
it('should detect JSON with expressions', () => {
|
|
||||||
expect(hasMixedContent('{"id": {{ $json.id }}, "name": "test"}')).toBe(true);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
describe('Pure expression cases', () => {
|
|
||||||
it('should return false for pure expression with = prefix', () => {
|
|
||||||
expect(hasMixedContent('={{ $json.value }}')).toBe(false);
|
|
||||||
});
|
|
||||||
|
|
||||||
it('should return true for {{ }} without = prefix (ambiguous case)', () => {
|
|
||||||
// Without = prefix, we can't distinguish between pure expression and mixed content
|
|
||||||
// So it's treated as mixed to be safe
|
|
||||||
expect(hasMixedContent('{{ $json.value }}')).toBe(true);
|
|
||||||
});
|
|
||||||
|
|
||||||
it('should return false for expression with whitespace', () => {
|
|
||||||
expect(hasMixedContent(' ={{ $json.value }} ')).toBe(false);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
describe('Non-expression cases', () => {
|
|
||||||
it('should return false for plain text', () => {
|
|
||||||
expect(hasMixedContent('plain text')).toBe(false);
|
|
||||||
});
|
|
||||||
|
|
||||||
it('should return false for literal URLs', () => {
|
|
||||||
expect(hasMixedContent('https://api.example.com')).toBe(false);
|
|
||||||
});
|
|
||||||
|
|
||||||
it('should return false for = prefix without {{ }}', () => {
|
|
||||||
expect(hasMixedContent('=$json.value')).toBe(false);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
describe('Edge cases', () => {
|
|
||||||
it('should return false for null', () => {
|
|
||||||
expect(hasMixedContent(null)).toBe(false);
|
|
||||||
});
|
|
||||||
|
|
||||||
it('should return false for undefined', () => {
|
|
||||||
expect(hasMixedContent(undefined)).toBe(false);
|
|
||||||
});
|
|
||||||
|
|
||||||
it('should return false for number', () => {
|
|
||||||
expect(hasMixedContent(123)).toBe(false);
|
|
||||||
});
|
|
||||||
|
|
||||||
it('should return false for object', () => {
|
|
||||||
expect(hasMixedContent({})).toBe(false);
|
|
||||||
});
|
|
||||||
|
|
||||||
it('should return false for array', () => {
|
|
||||||
expect(hasMixedContent([])).toBe(false);
|
|
||||||
});
|
|
||||||
|
|
||||||
it('should return false for empty string', () => {
|
|
||||||
expect(hasMixedContent('')).toBe(false);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
describe('Type guard effectiveness', () => {
|
|
||||||
it('should handle non-string types without calling containsExpression', () => {
|
|
||||||
// This tests the fix from Phase 1 - type guard must come before containsExpression
|
|
||||||
expect(() => hasMixedContent(123)).not.toThrow();
|
|
||||||
expect(() => hasMixedContent(null)).not.toThrow();
|
|
||||||
expect(() => hasMixedContent(undefined)).not.toThrow();
|
|
||||||
expect(() => hasMixedContent({})).not.toThrow();
|
|
||||||
});
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
describe('Integration scenarios', () => {
|
|
||||||
it('should correctly identify expression-based URL in HTTP Request node', () => {
|
|
||||||
const url = '={{ $json.baseUrl }}/users/{{ $json.userId }}';
|
|
||||||
|
|
||||||
expect(isExpression(url)).toBe(true);
|
|
||||||
expect(containsExpression(url)).toBe(true);
|
|
||||||
expect(shouldSkipLiteralValidation(url)).toBe(true);
|
|
||||||
expect(hasMixedContent(url)).toBe(true);
|
|
||||||
});
|
|
||||||
|
|
||||||
it('should correctly identify literal URL for validation', () => {
|
|
||||||
const url = 'https://api.example.com/users/123';
|
|
||||||
|
|
||||||
expect(isExpression(url)).toBe(false);
|
|
||||||
expect(containsExpression(url)).toBe(false);
|
|
||||||
expect(shouldSkipLiteralValidation(url)).toBe(false);
|
|
||||||
expect(hasMixedContent(url)).toBe(false);
|
|
||||||
});
|
|
||||||
|
|
||||||
it('should handle expression in JSON body', () => {
|
|
||||||
const json = '={{ { userId: $json.id, timestamp: $now } }}';
|
|
||||||
|
|
||||||
expect(isExpression(json)).toBe(true);
|
|
||||||
expect(shouldSkipLiteralValidation(json)).toBe(true);
|
|
||||||
expect(extractExpressionContent(json)).toBe('{ userId: $json.id, timestamp: $now }');
|
|
||||||
});
|
|
||||||
|
|
||||||
it('should handle webhook path with expressions', () => {
|
|
||||||
const path = '=/webhook/{{ $json.customerId }}/notify';
|
|
||||||
|
|
||||||
expect(isExpression(path)).toBe(true);
|
|
||||||
expect(containsExpression(path)).toBe(true);
|
|
||||||
expect(shouldSkipLiteralValidation(path)).toBe(true);
|
|
||||||
expect(extractExpressionContent(path)).toBe('/webhook/{{ $json.customerId }}/notify');
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
describe('Performance characteristics', () => {
|
|
||||||
it('should use efficient regex for containsExpression', () => {
|
|
||||||
// The implementation should use a single regex test, not two includes()
|
|
||||||
const value = 'text {{ expression }} more text';
|
|
||||||
const start = performance.now();
|
|
||||||
for (let i = 0; i < 10000; i++) {
|
|
||||||
containsExpression(value);
|
|
||||||
}
|
|
||||||
const duration = performance.now() - start;
|
|
||||||
|
|
||||||
// Performance test - should complete in reasonable time
|
|
||||||
expect(duration).toBeLessThan(100); // 100ms for 10k iterations
|
|
||||||
});
|
|
||||||
});
|
|
||||||
});
|
|
||||||
@@ -1,240 +0,0 @@
|
|||||||
import { describe, test, expect } from 'vitest';
|
|
||||||
import {
|
|
||||||
isStickyNote,
|
|
||||||
isTriggerNode,
|
|
||||||
isNonExecutableNode,
|
|
||||||
requiresIncomingConnection
|
|
||||||
} from '@/utils/node-classification';
|
|
||||||
|
|
||||||
describe('Node Classification Utilities', () => {
|
|
||||||
describe('isStickyNote', () => {
|
|
||||||
test('should identify standard sticky note type', () => {
|
|
||||||
expect(isStickyNote('n8n-nodes-base.stickyNote')).toBe(true);
|
|
||||||
});
|
|
||||||
|
|
||||||
test('should identify normalized sticky note type', () => {
|
|
||||||
expect(isStickyNote('nodes-base.stickyNote')).toBe(true);
|
|
||||||
});
|
|
||||||
|
|
||||||
test('should identify scoped sticky note type', () => {
|
|
||||||
expect(isStickyNote('@n8n/n8n-nodes-base.stickyNote')).toBe(true);
|
|
||||||
});
|
|
||||||
|
|
||||||
test('should return false for webhook node', () => {
|
|
||||||
expect(isStickyNote('n8n-nodes-base.webhook')).toBe(false);
|
|
||||||
});
|
|
||||||
|
|
||||||
test('should return false for HTTP request node', () => {
|
|
||||||
expect(isStickyNote('n8n-nodes-base.httpRequest')).toBe(false);
|
|
||||||
});
|
|
||||||
|
|
||||||
test('should return false for manual trigger node', () => {
|
|
||||||
expect(isStickyNote('n8n-nodes-base.manualTrigger')).toBe(false);
|
|
||||||
});
|
|
||||||
|
|
||||||
test('should return false for Set node', () => {
|
|
||||||
expect(isStickyNote('n8n-nodes-base.set')).toBe(false);
|
|
||||||
});
|
|
||||||
|
|
||||||
test('should return false for empty string', () => {
|
|
||||||
expect(isStickyNote('')).toBe(false);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
describe('isTriggerNode', () => {
|
|
||||||
test('should identify webhook trigger', () => {
|
|
||||||
expect(isTriggerNode('n8n-nodes-base.webhook')).toBe(true);
|
|
||||||
});
|
|
||||||
|
|
||||||
test('should identify webhook trigger variant', () => {
|
|
||||||
expect(isTriggerNode('n8n-nodes-base.webhookTrigger')).toBe(true);
|
|
||||||
});
|
|
||||||
|
|
||||||
test('should identify manual trigger', () => {
|
|
||||||
expect(isTriggerNode('n8n-nodes-base.manualTrigger')).toBe(true);
|
|
||||||
});
|
|
||||||
|
|
||||||
test('should identify cron trigger', () => {
|
|
||||||
expect(isTriggerNode('n8n-nodes-base.cronTrigger')).toBe(true);
|
|
||||||
});
|
|
||||||
|
|
||||||
test('should identify schedule trigger', () => {
|
|
||||||
expect(isTriggerNode('n8n-nodes-base.scheduleTrigger')).toBe(true);
|
|
||||||
});
|
|
||||||
|
|
||||||
test('should return false for HTTP request node', () => {
|
|
||||||
expect(isTriggerNode('n8n-nodes-base.httpRequest')).toBe(false);
|
|
||||||
});
|
|
||||||
|
|
||||||
test('should return false for Set node', () => {
|
|
||||||
expect(isTriggerNode('n8n-nodes-base.set')).toBe(false);
|
|
||||||
});
|
|
||||||
|
|
||||||
test('should return false for sticky note', () => {
|
|
||||||
expect(isTriggerNode('n8n-nodes-base.stickyNote')).toBe(false);
|
|
||||||
});
|
|
||||||
|
|
||||||
test('should return false for empty string', () => {
|
|
||||||
expect(isTriggerNode('')).toBe(false);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
describe('isNonExecutableNode', () => {
|
|
||||||
test('should identify sticky note as non-executable', () => {
|
|
||||||
expect(isNonExecutableNode('n8n-nodes-base.stickyNote')).toBe(true);
|
|
||||||
});
|
|
||||||
|
|
||||||
test('should identify all sticky note variations as non-executable', () => {
|
|
||||||
expect(isNonExecutableNode('nodes-base.stickyNote')).toBe(true);
|
|
||||||
expect(isNonExecutableNode('@n8n/n8n-nodes-base.stickyNote')).toBe(true);
|
|
||||||
});
|
|
||||||
|
|
||||||
test('should return false for webhook trigger', () => {
|
|
||||||
expect(isNonExecutableNode('n8n-nodes-base.webhook')).toBe(false);
|
|
||||||
});
|
|
||||||
|
|
||||||
test('should return false for HTTP request node', () => {
|
|
||||||
expect(isNonExecutableNode('n8n-nodes-base.httpRequest')).toBe(false);
|
|
||||||
});
|
|
||||||
|
|
||||||
test('should return false for Set node', () => {
|
|
||||||
expect(isNonExecutableNode('n8n-nodes-base.set')).toBe(false);
|
|
||||||
});
|
|
||||||
|
|
||||||
test('should return false for manual trigger', () => {
|
|
||||||
expect(isNonExecutableNode('n8n-nodes-base.manualTrigger')).toBe(false);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
describe('requiresIncomingConnection', () => {
|
|
||||||
describe('non-executable nodes (should not require connections)', () => {
|
|
||||||
test('should return false for sticky note', () => {
|
|
||||||
expect(requiresIncomingConnection('n8n-nodes-base.stickyNote')).toBe(false);
|
|
||||||
});
|
|
||||||
|
|
||||||
test('should return false for all sticky note variations', () => {
|
|
||||||
expect(requiresIncomingConnection('nodes-base.stickyNote')).toBe(false);
|
|
||||||
expect(requiresIncomingConnection('@n8n/n8n-nodes-base.stickyNote')).toBe(false);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
describe('trigger nodes (should not require incoming connections)', () => {
|
|
||||||
test('should return false for webhook', () => {
|
|
||||||
expect(requiresIncomingConnection('n8n-nodes-base.webhook')).toBe(false);
|
|
||||||
});
|
|
||||||
|
|
||||||
test('should return false for webhook trigger', () => {
|
|
||||||
expect(requiresIncomingConnection('n8n-nodes-base.webhookTrigger')).toBe(false);
|
|
||||||
});
|
|
||||||
|
|
||||||
test('should return false for manual trigger', () => {
|
|
||||||
expect(requiresIncomingConnection('n8n-nodes-base.manualTrigger')).toBe(false);
|
|
||||||
});
|
|
||||||
|
|
||||||
test('should return false for cron trigger', () => {
|
|
||||||
expect(requiresIncomingConnection('n8n-nodes-base.cronTrigger')).toBe(false);
|
|
||||||
});
|
|
||||||
|
|
||||||
test('should return false for schedule trigger', () => {
|
|
||||||
expect(requiresIncomingConnection('n8n-nodes-base.scheduleTrigger')).toBe(false);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
describe('regular nodes (should require incoming connections)', () => {
|
|
||||||
test('should return true for HTTP request node', () => {
|
|
||||||
expect(requiresIncomingConnection('n8n-nodes-base.httpRequest')).toBe(true);
|
|
||||||
});
|
|
||||||
|
|
||||||
test('should return true for Set node', () => {
|
|
||||||
expect(requiresIncomingConnection('n8n-nodes-base.set')).toBe(true);
|
|
||||||
});
|
|
||||||
|
|
||||||
test('should return true for Code node', () => {
|
|
||||||
expect(requiresIncomingConnection('n8n-nodes-base.code')).toBe(true);
|
|
||||||
});
|
|
||||||
|
|
||||||
test('should return true for Function node', () => {
|
|
||||||
expect(requiresIncomingConnection('n8n-nodes-base.function')).toBe(true);
|
|
||||||
});
|
|
||||||
|
|
||||||
test('should return true for IF node', () => {
|
|
||||||
expect(requiresIncomingConnection('n8n-nodes-base.if')).toBe(true);
|
|
||||||
});
|
|
||||||
|
|
||||||
test('should return true for Switch node', () => {
|
|
||||||
expect(requiresIncomingConnection('n8n-nodes-base.switch')).toBe(true);
|
|
||||||
});
|
|
||||||
|
|
||||||
test('should return true for Respond to Webhook node', () => {
|
|
||||||
expect(requiresIncomingConnection('n8n-nodes-base.respondToWebhook')).toBe(true);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
describe('edge cases', () => {
|
|
||||||
test('should return true for unknown node types (conservative approach)', () => {
|
|
||||||
expect(requiresIncomingConnection('unknown-package.unknownNode')).toBe(true);
|
|
||||||
});
|
|
||||||
|
|
||||||
test('should return true for empty string', () => {
|
|
||||||
expect(requiresIncomingConnection('')).toBe(true);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
describe('integration scenarios', () => {
|
|
||||||
test('sticky notes should be non-executable and not require connections', () => {
|
|
||||||
const stickyType = 'n8n-nodes-base.stickyNote';
|
|
||||||
expect(isNonExecutableNode(stickyType)).toBe(true);
|
|
||||||
expect(requiresIncomingConnection(stickyType)).toBe(false);
|
|
||||||
expect(isStickyNote(stickyType)).toBe(true);
|
|
||||||
expect(isTriggerNode(stickyType)).toBe(false);
|
|
||||||
});
|
|
||||||
|
|
||||||
test('webhook nodes should be triggers and not require incoming connections', () => {
|
|
||||||
const webhookType = 'n8n-nodes-base.webhook';
|
|
||||||
expect(isTriggerNode(webhookType)).toBe(true);
|
|
||||||
expect(requiresIncomingConnection(webhookType)).toBe(false);
|
|
||||||
expect(isNonExecutableNode(webhookType)).toBe(false);
|
|
||||||
expect(isStickyNote(webhookType)).toBe(false);
|
|
||||||
});
|
|
||||||
|
|
||||||
test('regular nodes should require incoming connections', () => {
|
|
||||||
const httpType = 'n8n-nodes-base.httpRequest';
|
|
||||||
expect(requiresIncomingConnection(httpType)).toBe(true);
|
|
||||||
expect(isNonExecutableNode(httpType)).toBe(false);
|
|
||||||
expect(isTriggerNode(httpType)).toBe(false);
|
|
||||||
expect(isStickyNote(httpType)).toBe(false);
|
|
||||||
});
|
|
||||||
|
|
||||||
test('all trigger types should not require incoming connections', () => {
|
|
||||||
const triggerTypes = [
|
|
||||||
'n8n-nodes-base.webhook',
|
|
||||||
'n8n-nodes-base.webhookTrigger',
|
|
||||||
'n8n-nodes-base.manualTrigger',
|
|
||||||
'n8n-nodes-base.cronTrigger',
|
|
||||||
'n8n-nodes-base.scheduleTrigger'
|
|
||||||
];
|
|
||||||
|
|
||||||
triggerTypes.forEach(type => {
|
|
||||||
expect(isTriggerNode(type)).toBe(true);
|
|
||||||
expect(requiresIncomingConnection(type)).toBe(false);
|
|
||||||
expect(isNonExecutableNode(type)).toBe(false);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
test('all sticky note variations should be non-executable', () => {
|
|
||||||
const stickyTypes = [
|
|
||||||
'n8n-nodes-base.stickyNote',
|
|
||||||
'nodes-base.stickyNote',
|
|
||||||
'@n8n/n8n-nodes-base.stickyNote'
|
|
||||||
];
|
|
||||||
|
|
||||||
stickyTypes.forEach(type => {
|
|
||||||
expect(isStickyNote(type)).toBe(true);
|
|
||||||
expect(isNonExecutableNode(type)).toBe(true);
|
|
||||||
expect(requiresIncomingConnection(type)).toBe(false);
|
|
||||||
expect(isTriggerNode(type)).toBe(false);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
});
|
|
||||||
});
|
|
||||||
@@ -206,7 +206,7 @@ describe('Validation System Fixes', () => {
|
|||||||
const result = await workflowValidator.validateWorkflow(workflow);
|
const result = await workflowValidator.validateWorkflow(workflow);
|
||||||
|
|
||||||
expect(result).toBeDefined();
|
expect(result).toBeDefined();
|
||||||
expect(result.statistics.totalNodes).toBe(1); // Only webhook, non-executable nodes excluded
|
expect(result.statistics.totalNodes).toBe(1); // Only webhook, sticky note excluded
|
||||||
expect(result.statistics.enabledNodes).toBe(1);
|
expect(result.statistics.enabledNodes).toBe(1);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user