重现
- 作者仓库星标 190,957
- 作者仓库 n8n
- 领域
- 工程开发
- 作者声明的智能体
- 未找到明确声明;不据此推断已兼容或已测试
- 静态检查
- 88 / 100 · 启发式扫描,不代表运行安全
- 运行环境证据
- 未执行;当前没有隔离运行测试证据
- 作者 / 版本 / 许可证
- @n8n-io · 未声明许可证
- 上下文用量评级
- 低消耗
- 接入复杂程度
- 需简单配置
- 是否需要外部接口密钥
- 不需要
- 兼容的系统
- macOS · Linux · Windows
- 运行环境要求
- Node.js
- 检测到的文件与系统行为
-
- 只读
- 允许写入 / 修改
- 命令执行
- 网络行为
- 允许外网请求
- 安装命令数
- 无(仅作为资料)
需要注意: 未声明工具权限范围;实际权限由运行环境决定。
从提供的票证上下文中提取以下内容: 错误消息/堆栈跟踪(如果提供) 复制步骤(如果提供) 工作流 JSON(如果附加) 受影响的区域(节点、执行引擎、编辑器、API、配置等)
根据受影响的区域,选择测试层和模式: 区域 · 测试层 · 模式 · 关键位置 节点操作 · Jest 单元 · NodeTestHarness + nock · `packages/nodes-base/nodes/*/test/` 节点凭证 · Jest 单元 · jest-mock-extend · `packages/nodes-base/nodes/*/test/` 触发 webhook · Jest 单元 · 模拟 IHookFunctions + jest.mock GenericFunctions · `packages/nodes-base/nodes/*/test/`
查找受影响区域的源代码: 搜索票证中提到的节点/服务/组件 查找 GenericFunctions 文件(节点的常见错误位置) 检查同一区域中现有的测试文件 查看受影响文件的最新 git 历史记录 (`git log --oneline -10 -- <path>`)
阅读源代码并跟踪触发 bug 的执行路径: 跟踪从入口点到故障的调用链 识别 bug 出现的特定行 注意 bug 周围的任何错误处理(或缺乏处理)
陈述一个清晰的、可测试的假设:“当[输入/条件]时,代码会因为[根本原因]而执行[错误的事情]” 确定需要更改的确切行 预测测试输出将显示的内容
查找同一区域中的现有测试: 检查受影响代码附近的 `test/` 目录 确定它们使用哪些模拟/设置模式 使用相同的模式以保持一致性 如果不存在测试,则查找最接近的相似节点/服务测试作为模板
编写一个回归测试: 使用第 6 步中找到的模式 针对第 5 步中的特定假设 包含引用票证 ID 的注释 断言正确的行为(测试将在当前代码上失败)
从包目录(例如,`cd packages/nodes-base && pnpm test <file>`)运行测试。对结果进行分类:置信度·标准·输出已确认·测试始终失败,失败符合假设·重现报告可能·测试失败但失败模式略有不同·报告+警告
# Bug Reproduction Framework
Given a Linear ticket context ($ARGUMENTS), systematically reproduce the bug
with a failing regression test.
## Step 1: Parse Signals
Extract the following from the provided ticket context:
- **Error message / stack trace** (if provided)
- **Reproduction steps** (if provided)
- **Workflow JSON** (if attached)
- **Affected area** (node, execution engine, editor, API, config, etc.)
- **Version where it broke / last working version**
## Step 2: Route to Test Strategy
Based on the affected area, pick the test layer and pattern:
| Area | Test Layer | Pattern | Key Location |
|------|-----------|---------|--------------|
| Node operation | Jest unit | NodeTestHarness + nock | `packages/nodes-base/nodes/*/test/` |
| Node credential | Jest unit | jest-mock-extended | `packages/nodes-base/nodes/*/test/` |
| Trigger webhook | Jest unit | mock IHookFunctions + jest.mock GenericFunctions | `packages/nodes-base/nodes/*/test/` |
| Binary data | Jest unit | NodeTestHarness assertBinaryData | `packages/core/nodes-testing/` |
| Execution engine | Jest integration | WorkflowRunner + DI container | `packages/cli/src/__tests__/` |
| CLI / API | Jest integration | setupTestServer + supertest | `packages/cli/test/integration/` |
| Config | Jest unit | GlobalConfig + Container | `packages/@n8n/config/src/__tests__/` |
| Editor UI | Vitest | Vue Test Utils + Pinia | `packages/frontend/editor-ui/src/**/__tests__/` |
| E2E / Canvas | Playwright | Test containers + composables | `packages/testing/playwright/` |
## Step 3: Locate Source Files
Find the source code for the affected area:
1. Search for the node/service/component mentioned in the ticket
2. Find the GenericFunctions file (common bug location for nodes)
3. Check for existing test files in the same area
4. Look at recent git history on affected files (`git log --oneline -10 -- <path>`)
## Step 4: Trace the Code Path
Read the source code and trace the execution path that triggers the bug:
- Follow the call chain from entry point to the failure
- Identify the specific line(s) where the bug manifests
- Note any error handling (or lack thereof) around the bug
## Step 5: Form Hypothesis
State a clear, testable hypothesis:
- "When [input/condition], the code does [wrong thing] because [root cause]"
- Identify the exact line(s) that need to change
- Predict what the test output will show
## Step 6: Find Test Patterns
Look for existing tests in the same area:
1. Check `test/` directories near the affected code
2. Identify which mock/setup patterns they use
3. Use the same patterns for consistency
4. If no tests exist, find the closest similar node/service tests as a template
## Step 7: Write Failing Test
Write a regression test that:
- Uses the patterns found in Step 6
- Targets the specific hypothesis from Step 5
- Includes a comment referencing the ticket ID
- Asserts the CORRECT behavior (test will fail on current code)
- Also includes a "happy path" test to prove the setup works
## Step 8: Run and Score
Run the test from the package directory (e.g., `cd packages/nodes-base && pnpm test <file>`).
Classify the result:
| Confidence | Criteria | Output |
|------------|----------|--------|
| **CONFIRMED** | Test fails consistently, failure matches hypothesis | Reproduction Report |
| **LIKELY** | Test fails but failure mode differs slightly | Report + caveat |
| **UNCONFIRMED** | Cannot trigger the failure | Report: what was tried |
| **SKIPPED** | Hit a hard bailout trigger | Report: why skipped |
| **ALREADY_FIXED** | Bug no longer reproduces on current code | Report: when fixed |
## Step 9: Iterate or Bail
If UNCONFIRMED after first attempt:
- Revisit hypothesis — re-read the code path
- Try a different test approach or layer
- Maximum 3 attempts before declaring UNCONFIRMED
**Hard bailout triggers** (stop immediately):
- Requires real third-party API credentials
- Race condition / timing-dependent
- Requires specific cloud/enterprise infrastructure
- Requires manual UI interaction that can't be scripted
## Output: Reproduction Report
Present findings in this format:
---
**Ticket:** [ID] — [title]
**Confidence:** [CONFIRMED | LIKELY | UNCONFIRMED | SKIPPED | ALREADY_FIXED]
### Root Cause
[1-2 sentences explaining the bug mechanism]
### Location
| File | Lines | Issue |
|------|-------|-------|
| `path/to/file.ts` | XX-YY | Description of the problem |
### Failing Test
`path/to/test/file.test.ts` — X/Y tests fail:
1. `test name` — [failure description]
### Fix Hint
[Pseudocode or description of the fix approach]
---
## Important
- **DO NOT fix the bug** — only reproduce it with a failing test
- **Leave test files in place** as evidence (don't commit unless asked)
- **Run tests from the package directory** (e.g., `pushd packages/nodes-base && pnpm test <file> && popd`)
- **Always redirect build output**: `pnpm build > build.log 2>&1`
- **DO NOT look at existing fix PRs** — the goal is to reproduce from signals alone
按说明文件中的顺序排列。
第 1 步:解析信号
第 2 步:测试策略的路径
第 3 步:找到源文件
第 4 步:跟踪代码路径
第五步:形成假设
文件/命令 -> packages/nodes-base/nodes/*/test/ · packages/core/nodes-testing/ · packages/cli/src/__tests__/ · packages/cli/test/integration/ · packages/@n8n/config/src/__tests__/ · packages/frontend/editor-ui/src/**/__tests__/ · packages/testing/playwright/ · git log --oneline -10 -- <path>
内容校验值 -> 976c485ae931
当前原文的自动摘译,尚未人工审校。
第 3 步:找到源文件
查找受影响区域的源代码: 搜索工单中提到的节点/服务/组件 查找 GenericFunctions 文件(节点的常见错误位置) 检查同一区域中现有的测试文件 查看受影响文件的最新 git 历史记录 (
git log --oneline -10 -- <path>)