From 7e80061e39f72bfa320e6b8ced454382cece58ec Mon Sep 17 00:00:00 2001 From: Taimoor Ahmed Date: Wed, 20 Aug 2025 13:24:05 +0500 Subject: [PATCH] fix: Discussion xblock error when loading for the first time This PR fixes the user not being created when accessing the discussion xblock as the course_key was missing in some of the api calls and that lead to the forum backend not being fetched correctly. --- .../djangoapps/django_comment_common/comment_client/user.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/openedx/core/djangoapps/django_comment_common/comment_client/user.py b/openedx/core/djangoapps/django_comment_common/comment_client/user.py index de676b77a8..969a8197d7 100644 --- a/openedx/core/djangoapps/django_comment_common/comment_client/user.py +++ b/openedx/core/djangoapps/django_comment_common/comment_client/user.py @@ -193,7 +193,7 @@ class User(models.Model): if course_id: course_id = str(course_id) retrieve_params['course_id'] = course_id - course_key = utils.get_course_key(course_id) + course_key = utils.get_course_key(course_id) or utils.get_course_key(kwargs.get("course_key")) if is_forum_v2_enabled(course_key): group_ids = [retrieve_params['group_id']] if 'group_id' in retrieve_params else [] @@ -207,6 +207,7 @@ class User(models.Model): try: response = forum_api.get_user(**params) except ForumV2RequestError as e: + course_id = str(course_key) self.save({"course_id": course_id}) response = forum_api.get_user(**params) else: