diff --git a/lms/djangoapps/discussion/rest_api/api.py b/lms/djangoapps/discussion/rest_api/api.py index e5f9bba3e8..e97c80b5d8 100644 --- a/lms/djangoapps/discussion/rest_api/api.py +++ b/lms/djangoapps/discussion/rest_api/api.py @@ -3,7 +3,6 @@ Discussion API internal interface """ from __future__ import annotations -import logging import itertools from collections import defaultdict from enum import Enum @@ -104,7 +103,6 @@ from .utils import ( ) User = get_user_model() -log = logging.getLogger(__name__) ThreadType = Literal["discussion", "question"] ViewType = Literal["unread", "unanswered"] @@ -614,12 +612,10 @@ def _get_users(discussion_entity_type, discussion_entity, username_profile_dict) """ users = {} if discussion_entity['author']: - try: - users[discussion_entity['author']] = _user_profile(username_profile_dict[discussion_entity['author']]) - except ValueError as value_error: - log.error(f'User Profile do not exists for Author :{discussion_entity["author"]} ' - f'profiles list: {username_profile_dict.keys()} ') - raise value_error + user_profile = username_profile_dict.get(discussion_entity['author']) + if user_profile: + users[discussion_entity['author']] = _user_profile(user_profile) + if ( discussion_entity_type == DiscussionEntity.comment and discussion_entity['endorsed']