mirror of
https://github.com/czlonkowski/n8n-mcp.git
synced 2026-02-14 17:13:08 +00:00
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:
committed by
GitHub
parent
a40f6a5077
commit
d60182eeb8
@@ -1421,17 +1421,33 @@ export async function handleGetExecution(args: unknown, context?: InstanceContex
|
||||
// Parse and validate input with new parameters
|
||||
const schema = z.object({
|
||||
id: z.string(),
|
||||
// New filtering parameters
|
||||
mode: z.enum(['preview', 'summary', 'filtered', 'full']).optional(),
|
||||
// Filtering parameters
|
||||
mode: z.enum(['preview', 'summary', 'filtered', 'full', 'error']).optional(),
|
||||
nodeNames: z.array(z.string()).optional(),
|
||||
itemsLimit: z.number().optional(),
|
||||
includeInputData: z.boolean().optional(),
|
||||
// Legacy parameter (backward compatibility)
|
||||
includeData: z.boolean().optional()
|
||||
includeData: z.boolean().optional(),
|
||||
// Error mode specific parameters
|
||||
errorItemsLimit: z.number().min(0).max(100).optional(),
|
||||
includeStackTrace: z.boolean().optional(),
|
||||
includeExecutionPath: z.boolean().optional(),
|
||||
fetchWorkflow: z.boolean().optional()
|
||||
});
|
||||
|
||||
const params = schema.parse(args);
|
||||
const { id, mode, nodeNames, itemsLimit, includeInputData, includeData } = params;
|
||||
const {
|
||||
id,
|
||||
mode,
|
||||
nodeNames,
|
||||
itemsLimit,
|
||||
includeInputData,
|
||||
includeData,
|
||||
errorItemsLimit,
|
||||
includeStackTrace,
|
||||
includeExecutionPath,
|
||||
fetchWorkflow
|
||||
} = params;
|
||||
|
||||
/**
|
||||
* Map legacy includeData parameter to mode for backward compatibility
|
||||
@@ -1470,15 +1486,33 @@ export async function handleGetExecution(args: unknown, context?: InstanceContex
|
||||
};
|
||||
}
|
||||
|
||||
// For error mode, optionally fetch workflow for accurate upstream detection
|
||||
let workflow: Workflow | undefined;
|
||||
if (effectiveMode === 'error' && fetchWorkflow !== false && execution.workflowId) {
|
||||
try {
|
||||
workflow = await client.getWorkflow(execution.workflowId);
|
||||
} catch (e) {
|
||||
// Workflow fetch failed - continue without it (use heuristics)
|
||||
logger.debug('Could not fetch workflow for error analysis', {
|
||||
workflowId: execution.workflowId,
|
||||
error: e instanceof Error ? e.message : 'Unknown error'
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
// Apply filtering using ExecutionProcessor
|
||||
const filterOptions: ExecutionFilterOptions = {
|
||||
mode: effectiveMode,
|
||||
nodeNames,
|
||||
itemsLimit,
|
||||
includeInputData
|
||||
includeInputData,
|
||||
// Error mode specific options
|
||||
errorItemsLimit,
|
||||
includeStackTrace,
|
||||
includeExecutionPath
|
||||
};
|
||||
|
||||
const processedExecution = processExecution(execution, filterOptions);
|
||||
const processedExecution = processExecution(execution, filterOptions, workflow);
|
||||
|
||||
return {
|
||||
success: true,
|
||||
|
||||
Reference in New Issue
Block a user