AOSSIE-Org / AOSSIE-Org/DebateAI

[Bug Report] Debate Outcome Not Persisted for Debate vs Bot

Offen
#228 1 Kommentar 0 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen
Vorherrschende Sprache
TypeScript
Sterne
84
Forks
198
Ø Merge
2 T. 19 Std.
Gemergte PRs (30 T.)
30

Beschreibung

## 📌 Summary
Debate outcomes for **Debate vs Bot** sessions are not being persisted in the database due to an identifier mismatch between the database schema and the update query. This causes silent failures where debate results (win/loss/draw) are never saved, breaking downstream logic such as Elo updates, analytics, and user performance tracking.

---

## 🧩 Affected Components
- **Database Layer:** `backend/db/db.go`
- **Controller:** `backend/controllers/debatevsbot_controller.go`
- **Feature Area:** Debate vs Bot → Judging & Outcome Persistence

---

## 🔍 Root Cause Analysis
The database update function filters by `userId`, while the underlying MongoDB model stores `email`. The controller passes an email string to the update function, resulting in zero documents matched and no errors surfaced.

---

However:

- The DebateVsBot MongoDB model does not store userId
- It stores the user's email instead
- The controller passes an email string to this function

- This results in:

- MongoDB update query matching zero documents
- No error returned
- Silent failure

---

## ❌ Expected Behavior

- When a Debate vs Bot session is judged:
- The corresponding debate record should be updated with the correct outcome
- The update should target the correct debate document

---

## ✅ Actual Behavior

- No document is matched
- Debate outcome is never updated
- Application behaves as if the update succeeded

---

## 🧪 Steps to Reproduce

- Start a Debate vs Bot session
- Complete the debate and trigger judging
- Check the debate_vs_bot collection in MongoDB
- Observe that the outcome field remains unchanged or missing

---

## 💥 Impact

- Breaks debate result persistence
- Corrupts user statistics
- Makes Elo calculation and performance analytics inaccurate
- Silent failure makes debugging difficult

I am willing to submit a PR.

Beitragsleitfaden

Für dieses Repository ist kein Beitragsleitfaden indexiert

Bewertung

Dieses Issue wurde noch nicht bewertet.

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.