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

オープン 初心者向け
#39,225 コメント 1 件 リアクション 0 件 担当者 0 名 GitHub で見る

メンテナーはふだん 1 日以内に返信

@mbhavu2007-lang がすでに取り組んでいます。

2026年10月31日 から。

評価

難易度
2/5
見積もり時間
1〜3時間
初心者へのやさしさ
72/100
issue の種類
バグ
明瞭さ
明確に書かれている
活発さ
活発
技術スタック
mysql, python
領域
api, backend

調査の方向性

lms/djangoapps/discussion/rest_api/api.py の _get_thread_and_context と _get_comment_and_context から確認してください。これらはスレッドやコメントが存在しない場合に CommentClientRequestError を捕捉しています。失敗している呼び出しは comment_client/thread.py の Thread._retrieve で、forum.api.get_thread を呼び出し、forum.utils.ForumV2RequestError をそのまま上に伝播させています。このエラーを comment client 内で CommentClientRequestError に変換するか、これらの関数の except 節で捕捉するかのどちらかで対応してください。存在しないスレッドに対する DELETE、GET、PATCH が 500 ではなく 404 を返し、それをカバーするテストがあれば完了です。

索引モデルが issue の本文から書いたものです。

説明

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.

主要言語
Python
スター
8.2k
フォーク
4.4k
平均マージ
2日 10時間
マージ済み PR(30日)
40

環境構築

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

openedx/openedx-platform のほかの issue

openedx/openedx-platform の issue をすべて見る

似ている issue

Python の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。