Discussion API: missing thread returns 500 (ForumV2RequestError not mapped to ThreadNotFoundError)

Aperta Adatta ai principianti
#39,225 1 commento 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

@mbhavu2007-lang ci sta già lavorando.

Dal 31/10/2026.

Valutazione

Difficoltà
2/5
Tempo stimato
1-3 ore
Idoneità per principianti
72/100
Tipo di issue
Bug
Chiarezza
Specificata chiaramente
Stato di attività
Attiva
Stack tecnologico
mysql, python
Ambito
api, backend

Direzione di ricerca

Inizia da lms/djangoapps/discussion/rest_api/api.py in _get_thread_and_context e _get_comment_and_context, che intercettano CommentClientRequestError quando un thread o un commento manca. La chiamata che fallisce è Thread._retrieve in comment_client/thread.py, che richiama forum.api.get_thread e lascia propagare forum.utils.ForumV2RequestError. Puoi tradurre quell'errore in CommentClientRequestError nel comment client oppure intercettarlo nelle clausole except di quelle funzioni. È completato quando un DELETE, GET o PATCH su un thread mancante restituisce 404 invece di 500, con un test che lo copra.

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

Descrizione

With the forum v2 backend (openedx/forum, used in-process), DELETE /api/discussion/v1/threads/<id>/ for a thread that no longer exists returns a bare 500, not 404:

forum.utils.ForumV2RequestError: Thread does not exist with Id: 137
  File ".../forum/api/threads.py", line 141, in get_thread
  File ".../forum/backends/mysql/api.py", line 993, in validate_object
    raise self.model.DoesNotExist(
Internal Server Error: /api/discussion/v1/threads/137/

Cause: _get_thread_and_context in lms/djangoapps/discussion/rest_api/api.py turns a missing thread into ThreadNotFoundError (404) by catching CommentClientRequestError, the error the old HTTP comments-service client raised. The comment client now calls forum.api.get_thread directly (comment_client/thread.py, Thread._retrieve), which raises forum.utils.ForumV2RequestError instead. Nothing maps it, so it escapes as a 500. Any endpoint that goes through _get_thread_and_context should behave the same way (GET/PATCH/DELETE of a thread, and a thread's comment list). The same except CommentClientRequestError pattern is used elsewhere in the module, e.g. _get_comment_and_context.

Impact: a client cannot tell "already deleted" from a server fault. An idempotent cleanup, such as a retry or a teardown after the UI deleted the post, fails with a 500 and an error in the logs.

Expected: 404, as before. Either the comment client translates ForumV2RequestError into CommentClientRequestError, or these except clauses also catch it.

Environment: Tutor main with tutor-forum, openedx-forum 0.4.7 (MySQL backend), 2026-09-23. Code unchanged on master as of 2026-10-13. Found by the Open edX end-to-end test suite.

Lingua principale
Python
Stelle
8.2k
Fork
4.4k
Merge medio
2g 10h
PR unite (30g)
40

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 openedx/openedx-platform

Tutte le issue di openedx/openedx-platform

Issue simili

Altre issue su Python

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.