feat: add error mode for execution debugging with AI suggestions (#505)

* feat: add error mode for execution debugging with AI suggestions

Add a new `mode='error'` option to n8n_executions action=get that's optimized
for AI agents debugging workflow failures. This mode provides intelligent
error extraction with 80-99% token savings compared to `mode='full'`.

Key features:
- Error Analysis: Extracts error message, type, node name, and parameters
- Upstream Context: Samples input data from upstream node (configurable limit)
- Execution Path: Shows node execution sequence from trigger to error
- AI Suggestions: Pattern-based fix suggestions for common errors
- Workflow Fetch: Optionally fetches workflow for accurate upstream detection

New parameters for mode='error':
- errorItemsLimit (default: 2) - Sample items from upstream node
- includeStackTrace (default: false) - Full vs truncated stack trace
- includeExecutionPath (default: true) - Include node execution path
- fetchWorkflow (default: true) - Fetch workflow for upstream detection

Token efficiency:
- 11 items: ~11KB full vs ~3KB error (73% savings)
- 1001 items: ~354KB full vs ~3KB error (99% savings)

Conceived by Romuald Członkowski - https://www.aiadvisors.pl/en

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>

* fix: add security hardening to error-execution-processor

- Add prototype pollution protection (block __proto__, constructor, prototype)
- Expand sensitive data patterns (20+ patterns including JWT, OAuth, certificates)
- Create recursive sanitizeData function for deep object sanitization
- Apply sanitization to both nodeParameters and upstream sampleItems
- Add comprehensive unit tests (42 tests, 96% coverage)

Security improvements address code review findings:
- Critical: Prototype pollution protection
- Warning: Expanded sensitive data filtering
- Warning: Nested data sanitization

Concieved by Romuald Członkowski - www.aiadvisors.pl/en

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>

---------

Co-authored-by: Romuald Członkowski <romualdczlonkowski@MacBook-Pro-Romuald.local>
Co-authored-by: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
Romuald Członkowski
2025-12-23 17:14:30 +01:00
committed by GitHub
parent a40f6a5077
commit d60182eeb8
9 changed files with 1800 additions and 20 deletions

View File

@@ -321,7 +321,7 @@ export interface McpToolResponse {
}
// Execution Filtering Types
export type ExecutionMode = 'preview' | 'summary' | 'filtered' | 'full';
export type ExecutionMode = 'preview' | 'summary' | 'filtered' | 'full' | 'error';
export interface ExecutionPreview {
totalNodes: number;
@@ -354,6 +354,10 @@ export interface ExecutionFilterOptions {
itemsLimit?: number;
includeInputData?: boolean;
fieldsToInclude?: string[];
// Error mode specific options
errorItemsLimit?: number; // Sample items from upstream node (default: 2)
includeStackTrace?: boolean; // Include full stack trace (default: false)
includeExecutionPath?: boolean; // Include execution path to error (default: true)
}
export interface FilteredExecutionResponse {
@@ -381,6 +385,9 @@ export interface FilteredExecutionResponse {
// Error information
error?: Record<string, unknown>;
// Error mode specific (mode='error')
errorInfo?: ErrorAnalysis;
}
export interface FilteredNodeData {
@@ -398,4 +405,51 @@ export interface FilteredNodeData {
truncated: boolean;
};
};
}
// Error Mode Types
export interface ErrorAnalysis {
// Primary error information
primaryError: {
message: string;
errorType: string; // NodeOperationError, NodeApiError, etc.
nodeName: string;
nodeType: string;
nodeId?: string;
nodeParameters?: Record<string, unknown>; // Relevant params only (no secrets)
stackTrace?: string; // Truncated by default
};
// Upstream context (input to error node)
upstreamContext?: {
nodeName: string;
nodeType: string;
itemCount: number;
sampleItems: unknown[]; // Configurable limit, default 2
dataStructure: Record<string, unknown>;
};
// Execution path leading to error (from trigger to error)
executionPath?: Array<{
nodeName: string;
status: 'success' | 'error' | 'skipped';
itemCount: number;
executionTime?: number;
}>;
// Additional errors (if workflow had multiple failures)
additionalErrors?: Array<{
nodeName: string;
message: string;
}>;
// AI-friendly suggestions
suggestions?: ErrorSuggestion[];
}
export interface ErrorSuggestion {
type: 'fix' | 'investigate' | 'workaround';
title: string;
description: string;
confidence: 'high' | 'medium' | 'low';
}