AOSSIE-Org / AOSSIE-Org/DebateAI

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

Open
#228 1 comment 0 reactions 0 assignees View on GitHub
Dominant language
TypeScript
Stars
84
Forks
198
Avg merge
2d 19h
Merged PRs (30d)
30

Description

## 📌 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.

Contributor guide

No contributing guide indexed for this repository

Research direction

Start in backend/db/db.go and backend/controllers/debatevsbot_controller.go, comparing the update filter with the DebateVsBot fields and the value passed during judging. Reproduce the flow, then inspect the debate_vs_bot collection to confirm that the judged outcome is persisted on the intended record and that the update no longer silently matches zero documents.

Written by the indexing model from the issue text.

Assessment

Tech stack
go, mongodb
Domain
backend, databases
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
52/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.