Hacktoberfest 2026: le issue che i maintainer hanno segnato per ottobre, aperte e adatte ai principianti. Sfoglia le issue Hacktoberfest

[BUG]: Coach Service Updates Non-Existent Field (total_points vs score)

Aperta Adatta ai principianti
#773 2 commenti 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

@Basharkhan7776 ci sta già lavorando.

Dal 24/10/2026.

Valutazione

Difficoltà
1/5
Tempo stimato
Meno di un'ora
Idoneità per principianti
85/100
Tipo di issue
Bug
Chiarezza
Specificata chiaramente
Stato di attività
Attiva
Stack tecnologico
go, mongodb
Ambito
backend, databases

Direzione di ricerca

Apri backend/services/coach.go alla riga 117 e cambia il campo $inc da total_points a score per corrispondere al modello User in backend/models/user.go:33. Esegui il test temporaneo TestBUG06_UpdateUserPoints_WritesUnmappedField o avvia MongoDB e chiama POST /coach/strengthen-argument/evaluate per verificare. Fatto significa che lo score dell'utente si incrementa e nessun campo total_points viene creato.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

bug
Bug Description

UpdateUserPoints increments a field named total_points, but the User model only defines score:

// backend/services/coach.go:117

func UpdateUserPoints(userID interface{}, points int) error {
	_, err := db.MongoDatabase.Collection("users").UpdateOne(
		context.Background(),
		bson.M{"_id": userID},
		bson.M{"$inc": bson.M{"total_points": points}},
	)
	return err
}

// backend/models/user.go:33

Score int `bson:"score" json:"score"`

MongoDB is schemaless, so the update succeeds and silently creates a new total_points field on the user document. Because no Go code reads total_points, the mapped score never changes, and the awarded points never appear in profiles or leaderboards.

Both coach flows call this helper:

  • EvaluateStrengthenedArgument awards evaluation.Score * 10 points (routes/coach.go:61-65).
  • SubmitProsCons awards evaluation.Score points (routes/coach.go:151).
Steps to Reproduce
  1. Start MongoDB via Docker:
    docker start debateai-mongo-1
  2. Insert a user with score: 100.
  3. Call the coach points helper for that user:
    services.UpdateUserPoints(user.ID, 50)
    (In the app this is triggered by POST /coach/strengthen-argument/evaluate or POST /coach/pros-cons/submit.)
  4. Read the user document:
db.users.findOne({ email: "[email protected]" })
// { ..., score: 100, total_points: 50 }

Automated reproduction used a temporary test (TestBUG06_UpdateUserPoints_WritesUnmappedField) that inserts a user with score = 100, calls UpdateUserPoints(userID, 50), and inspects both the typed model and the raw BSON document.

Logs and Screenshots
=== RUN   TestBUG06_UpdateUserPoints_WritesUnmappedField
    zz_bug06_tmp_test.go:64: user before: score=100, awarded=50
    zz_bug06_tmp_test.go:65: user after: score=100, total_points=50
    zz_bug06_tmp_test.go:74: BUG CONFIRMED: UpdateUserPoints wrote total_points=50 while mapped score stayed 100
--- PASS: TestBUG06_UpdateUserPoints_WritesUnmappedField (0.05s)
PASS
ok  	arguehub/services	0.062s
Environment Details
  • OS: Linux (x86_64)
  • Go: go1.24
  • Framework: Gin Gonic v1.9.1
  • Database: MongoDB 7.0 (debateai-mongo-1, port 27017)
  • Cache: Redis 7-Alpine (debateai-redis-1, port 6379)
  • Affected endpoints: POST /coach/strengthen-argument/evaluate, POST /coach/pros-cons/submit
  • Affected code: backend/services/coach.go:117-123
  • Severity: High (Defect / Gamification data loss)
Impact

High - Major feature is broken

Code of Conduct
  • I have joined the Discord server and will post updates there
  • I have searched existing issues to avoid duplicates
Lingua principale
TypeScript
Stelle
105
Fork
258
Merge medio
1g 21h
PR unite (30g)
43

Preparare l'ambiente

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di AOSSIE-Org/DebateAI

Tutte le issue di AOSSIE-Org/DebateAI

Issue simili

Altre issue su TypeScript

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.