docs: Add Common Pitfall #79 - n8n undefined signalStrength field causing SHORT signal failures
This commit is contained in:
69
.github/copilot-instructions.md
vendored
69
.github/copilot-instructions.md
vendored
@@ -3182,6 +3182,75 @@ This section contains the **TOP 10 MOST CRITICAL** pitfalls that every AI agent
|
||||
|
||||
📚 **Full Documentation:** `docs/COMMON_PITFALLS.md` (73 pitfalls with code examples, git commits, deployment dates)
|
||||
|
||||
79. **CRITICAL: n8n Undefined Field Reference - SHORT Signals Failing (CRITICAL - Dec 12, 2025):**
|
||||
- **Symptom:** SHORT signals stopped at Execute Trade1 node with error "JSON parameter needs to be valid JSON"
|
||||
- **User Report:** "last short signal stopped in n8n at the execute trade 1 with the error JSON parameter needs to be valid JSON"
|
||||
- **Financial Impact:** Part of $1,000+ losses - SHORT trades not executing in production
|
||||
- **Root Cause:**
|
||||
* File: `workflows/trading/Money_Machine.json` - Execute Trade1 node (id: 9902ecc4)
|
||||
* Line ~430: jsonBody parameter included `"signalStrength": "{{ $('Parse Signal Enhanced').item.json.signalStrength }}"`
|
||||
* Parse Signal Enhanced node DOES NOT extract or define signalStrength field
|
||||
* Workflow tried to interpolate undefined variable → malformed JSON → validation error
|
||||
* Orphaned reference: Field likely removed from parser in past update but not cleaned from downstream nodes
|
||||
- **Parse Signal Enhanced Actual Output:**
|
||||
* Extracts: symbol, direction, timeframe, atr, adx, rsi, volumeRatio, pricePosition, indicatorVersion
|
||||
* Calculates: signalPrice (uses pricePosition value)
|
||||
* Does NOT extract: signalStrength (field doesn't exist in code)
|
||||
- **THE FIX (Dec 12, 2025):**
|
||||
```json
|
||||
// BEFORE (line ~430 in Money_Machine.json):
|
||||
"jsonBody": {
|
||||
"symbol": "{{ $('Parse Signal Enhanced').item.json.symbol }}",
|
||||
"direction": "{{ $('Parse Signal Enhanced').item.json.direction }}",
|
||||
"signalStrength": "{{ $('Parse Signal Enhanced').item.json.signalStrength }}", // ❌ UNDEFINED
|
||||
...
|
||||
}
|
||||
|
||||
// AFTER:
|
||||
"jsonBody": {
|
||||
"symbol": "{{ $('Parse Signal Enhanced').item.json.symbol }}",
|
||||
"direction": "{{ $('Parse Signal Enhanced').item.json.direction }}",
|
||||
// signalStrength removed entirely
|
||||
...
|
||||
}
|
||||
```
|
||||
- **Why This Broke SHORT Signals:**
|
||||
* Execute Trade1 node sends HTTP POST to bot's /api/trading/execute endpoint
|
||||
* Malformed JSON causes n8n to abort workflow execution
|
||||
* Error appears at Execute Trade1 node, preventing API call from reaching bot
|
||||
* Bot never receives signal → no trade opened → Position Manager never monitors
|
||||
* User may not notice until checking n8n logs or missing expected positions
|
||||
- **Manual Fix Required (n8n UI):**
|
||||
* n8n workflows stored in n8n database, NOT in git-tracked JSON files
|
||||
* Git fix updates source files but doesn't auto-update running workflows
|
||||
* User must: Open https://flow.egonetix.de → Money Machine workflow → Execute Trade1 node → Remove signalStrength line → Save workflow
|
||||
* Alternative: Import fixed Money_Machine.json via n8n UI
|
||||
- **Files Changed:**
|
||||
* workflows/trading/Money_Machine.json (line ~430 removed)
|
||||
- **Verification Required:**
|
||||
* Monitor next SHORT signal execution in n8n logs
|
||||
* Confirm no "JSON parameter" error at Execute Trade1
|
||||
* Verify trade executes successfully and Position Manager starts monitoring
|
||||
* Check Telegram notification shows position opened
|
||||
- **Prevention Rules:**
|
||||
1. ALWAYS audit downstream nodes when removing fields from parser nodes
|
||||
2. NEVER leave orphaned field references in n8n workflows
|
||||
3. Test workflow changes with actual alert payload before deploying to production
|
||||
4. Document all n8n workflow field dependencies (what depends on what)
|
||||
5. Remember: n8n workflows require MANUAL UI update after JSON file changes
|
||||
6. Add n8n workflow testing to deployment checklist
|
||||
- **Red Flags Indicating This Bug:**
|
||||
* Specific signal direction fails (SHORT) but other direction works (LONG)
|
||||
* Error message: "JSON parameter needs to be valid JSON"
|
||||
* Error occurs at Execute Trade node, not at Parse Signal or Check Risk
|
||||
* n8n logs show workflow stops before bot API is called
|
||||
* No corresponding error in bot container logs (bot never receives request)
|
||||
* Check n8n node code for field references that don't exist in upstream output
|
||||
- **Git commits:** 74b6103 "fix: Remove undefined signalStrength field from Execute Trade1 node" (Dec 12, 2025)
|
||||
- **Deployment:** Git fixed, user must manually update n8n workflow via UI
|
||||
- **Status:** ✅ JSON FILE FIXED - Awaiting manual n8n workflow update + production verification
|
||||
- **See:** `/tmp/n8n_workflow_fix.md` for manual update instructions
|
||||
|
||||
75. **CRITICAL: Wrong Year in SQL Queries - ALWAYS Use Current Year (CRITICAL - Dec 8, 2025):**
|
||||
- **Symptom:** Query returns 247 rows spanning months when expecting 5-6 recent trades
|
||||
- **Root Cause:** Database stores timestamps in 2024 format, AI agent queried '2024-12-07' instead of '2025-12-07'
|
||||
|
||||
Reference in New Issue
Block a user