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

Abierto Apto para principiantes
#39,225 1 comentario 0 reacciones 0 asignados Ver en GitHub

Los mantenedores suelen responder en 1 día

@mbhavu2007-lang ya está trabajando en esto.

Desde el 31/10/2026.

Evaluación

Dificultad
2/5
Tiempo estimado
1-3 horas
Aptitud para principiantes
72/100
Tipo de issue
Error
Claridad
Bien especificado
Estado de actividad
Activo
Stack tecnológico
mysql, python
Área
api, backend

Línea de trabajo

Empieza en lms/djangoapps/discussion/rest_api/api.py en _get_thread_and_context y _get_comment_and_context, que capturan CommentClientRequestError cuando falta un hilo o un comentario. La llamada que falla es Thread._retrieve en comment_client/thread.py, que llama a forum.api.get_thread y deja escapar forum.utils.ForumV2RequestError. Puedes traducir ese error a CommentClientRequestError en el cliente de comentarios o capturarlo en las cláusulas except de esas funciones. Está terminado cuando un DELETE, GET o PATCH sobre un hilo inexistente devuelve 404 en lugar de 500, con una prueba que lo cubra.

Escrito por el modelo de indexación a partir del texto del issue.

Descripción

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.

Lenguaje dominante
Python
Estrellas
8.2k
Forks
4.4k
Merge medio
2 d 10 h
PR fusionados (30 d)
40

Preparar el entorno

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Más de openedx/openedx-platform

Todos los issues de openedx/openedx-platform

Issues similares

Más issues de Python

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.