fix: Smart Validation Queue respects symbol enabled status (Bug #79)

CRITICAL FIX - Stops Telegram notification spam for disabled symbols

Problem:
- User receiving unwanted notifications for FARTCOIN (enabled=false)
- Three notification types: QUEUED, VALIDATED, ENTERING NOW
- Smart Validation Queue queued quality 50-89 signals WITHOUT checking enabled
- Data collection working correctly, but validation queue also triggered

Root Cause:
- check-risk/route.ts lines 442-455 added signals to queue without enabled check
- Validation queue sends Telegram at multiple stages (queued, validated, entering)
- Execute endpoint checks enabled (line 290) but TOO LATE (after notifications)

The Fix:
- Added enabled status check BEFORE queueing signals
- Check: getActualPositionSizeForSymbol(symbol, config).enabled
- If disabled: Skip queue, save to database silently (data collection only)
- If enabled: Queue normally with notifications (SOL/BTC/ETH production trading)

Files Changed:
- app/api/trading/check-risk/route.ts: Lines 442-470 (added enabled check)
- .github/copilot-instructions.md: Bug #79 documented in Common Pitfalls

Expected Result:
- No more FARTCOIN Telegram notifications
- 1-minute data collection continues silently
- Only enabled symbols (SOL/BTC/ETH) send validation notifications

Severity: 6/10 (annoying but not financially harmful)
Status: Code fixed, awaiting deployment verification
This commit is contained in:
mindesbunister
2025-12-15 10:34:18 +01:00
parent 5aad42f25f
commit 90e403e302
2 changed files with 99 additions and 17 deletions

View File

@@ -3253,7 +3253,80 @@ 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):**
79. **CRITICAL: Smart Validation Queue Ignores Symbol Enabled Status - Telegram Spam (CRITICAL - Dec 15, 2025):**
- **Symptom:** Receiving Telegram notifications ("SIGNAL QUEUED", "SIGNAL VALIDATED", "ENTERING NOW") for symbols not trading (e.g., FARTCOIN enabled=false)
- **User Report:** "can you please check for the fartcoin data collection. i dont want to receive notifications in telegram as we are not trading it currently"
- **Financial Impact:** Notification spam for data-collection-only symbols, user confusion, unnecessary monitoring
- **Root Cause:**
* File: `app/api/trading/check-risk/route.ts` lines 442-455
* Smart Validation Queue queues quality 50-89 signals WITHOUT checking if symbol trading enabled
* Code pattern:
```typescript
if (isInValidationRange) {
const validationQueue = getSmartValidationQueue()
const normalizedSymbol = normalizeTradingViewSymbol(body.symbol)
// BUG: No check for enabled status before queueing
await validationQueue.addSignal({ symbol: normalizedSymbol, ... })
}
```
* Validation queue sends Telegram notifications at multiple stages (queued, validated, entering)
* Execute endpoint checks enabled status (line 290-310) but TOO LATE (after notifications sent)
- **Evidence:**
* Docker logs: "⏰ Smart validation queued: FARTCOIN-PERP SHORT @ $13.21 (quality: 60)"
* Docker logs: "✅ VALIDATED ENTRY BYPASS: Quality 60 accepted"
* Config: `fartcoin: { enabled: false }` at line 147
* System correctly collecting 1-min data but also sending validation notifications
- **THE FIX (Dec 15, 2025):**
```typescript
// BEFORE (lines 442-455 - BROKEN):
if (isInValidationRange) {
const validationQueue = getSmartValidationQueue()
const normalizedSymbol = normalizeTradingViewSymbol(body.symbol)
await validationQueue.addSignal({ ... }) // ❌ No enabled check
}
// AFTER (FIXED):
if (isInValidationRange) {
const validationQueue = getSmartValidationQueue()
const normalizedSymbol = normalizeTradingViewSymbol(body.symbol)
// Check if symbol trading enabled BEFORE queueing
const { enabled } = getActualPositionSizeForSymbol(normalizedSymbol, config)
if (!enabled) {
console.log(`⛔ Skipping validation queue: ${normalizedSymbol} trading disabled (data collection only)`)
} else {
await validationQueue.addSignal({ ... }) // ✅ Only queue if enabled
}
}
```
- **Why This Matters:**
* **This is a REAL MONEY system** - data collection symbols should be silent
* User only wants notifications for SOL-PERP, BTC-PERP, ETH-PERP (enabled symbols)
* Validation queue designed for marginal quality signals (50-89) to confirm before execution
* But shouldn't send notifications for symbols user isn't trading
* 1-minute data collection continues silently (correct behavior)
- **Prevention Rules:**
1. ALWAYS check enabled status before adding signals to validation queue
2. NEVER send Telegram notifications for disabled symbols
3. Data collection (BlockedSignal database) should continue for analysis
4. Validation queue is for TRADING validation, not data collection
5. Execute endpoint enabled check (line 290-310) is backup, not primary
6. Check-risk endpoint must be first line of defense for symbol filtering
- **Red Flags Indicating This Bug:**
* Telegram notifications for symbols with enabled=false in config
* User asks "why am I receiving notifications for X?"
* Docker logs show "Smart validation queued" for disabled symbols
* System correctly saves to BlockedSignal but also sends Telegram
* Multiple notification types (QUEUED, VALIDATED, ENTERING) for data collection signals
- **Files Changed:**
* app/api/trading/check-risk/route.ts: Lines 442-470 (added enabled check before queueing)
- **Git commit:** [CURRENT] "fix: Smart Validation Queue respects symbol enabled status" (Dec 15, 2025)
- **Deployment:** Pending build + restart
- **Status:** ✅ CODE FIXED - Awaiting deployment verification
- **Expected Result:** No more FARTCOIN Telegram notifications, 1-min data collection continues silently
80. **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

View File

@@ -447,23 +447,32 @@ export async function POST(request: NextRequest): Promise<NextResponse<RiskCheck
// CRITICAL FIX (Dec 1, 2025): Normalize TradingView symbol format to Drift format
const normalizedSymbol = normalizeTradingViewSymbol(body.symbol)
const queued = await validationQueue.addSignal({
blockReason: 'SMART_VALIDATION_QUEUED',
symbol: normalizedSymbol,
direction: body.direction,
originalPrice: currentPrice,
qualityScore: qualityScore.score,
atr: body.atr,
adx: body.adx,
rsi: body.rsi,
volumeRatio: body.volumeRatio,
pricePosition: body.pricePosition,
indicatorVersion: body.indicatorVersion || 'v5',
timeframe: body.timeframe || '5',
})
// CRITICAL FIX (Dec 15, 2025): Check if symbol trading is enabled BEFORE queueing
// Don't send Telegram notifications for data-collection-only symbols
const { enabled } = getActualPositionSizeForSymbol(normalizedSymbol, config)
if (queued) {
console.log(`🧠 Signal queued for smart validation: ${normalizedSymbol} ${body.direction} (quality ${qualityScore.score})`)
if (!enabled) {
console.log(` Skipping validation queue: ${normalizedSymbol} trading disabled (data collection only)`)
console.log(` Signal will be saved to database for analysis without notifications`)
} else {
const queued = await validationQueue.addSignal({
blockReason: 'SMART_VALIDATION_QUEUED',
symbol: normalizedSymbol,
direction: body.direction,
originalPrice: currentPrice,
qualityScore: qualityScore.score,
atr: body.atr,
adx: body.adx,
rsi: body.rsi,
volumeRatio: body.volumeRatio,
pricePosition: body.pricePosition,
indicatorVersion: body.indicatorVersion || 'v5',
timeframe: body.timeframe || '5',
})
if (queued) {
console.log(`🧠 Signal queued for smart validation: ${normalizedSymbol} ${body.direction} (quality ${qualityScore.score})`)
}
}
} else {
console.log(`❌ Signal quality too low for validation: ${qualityScore.score} (need 50-89 range)`)