Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Discussion XBlocks are not working #149

Open
muhammadadeeltajamul opened this issue Jan 16, 2025 · 18 comments · May be fixed by #160
Open

Discussion XBlocks are not working #149

muhammadadeeltajamul opened this issue Jan 16, 2025 · 18 comments · May be fixed by #160
Assignees
Labels
bug Report of or fix for something that isn't working as intended release blocker Blocks the upcoming release (fix needed)

Comments

@muhammadadeeltajamul
Copy link

Discussion xblocks are breaking when Forum V2 is enabled. This issue could impact Open edX community as default provider for them uses discussion xblocks, and they fail to load when the Forum v2 is active. This is also breaking old UI of discussions experience.

How to reproduce:

  • Enable Forum V2 for a course that is using old discussion provider
  • Navigate to the any discussions xblock
  • It will fail to load it
@muhammadadeeltajamul muhammadadeeltajamul added bug Report of or fix for something that isn't working as intended release blocker Blocks the upcoming release (fix needed) labels Jan 16, 2025
@regisb
Copy link
Contributor

regisb commented Jan 16, 2025

Can you share the stracktrace from the backend?

Also, what do you mean by "Enable Forum V2 for a course that is using old discussion provider"?

@muhammadadeeltajamul
Copy link
Author

I am not sure if stack-trace will be helpful since there may be more than one errors. Reproducing it and debugging it locally will be a better approach.

edX support two native discussion provider (rest of discussion providers are third-party providers). Old discussion provider uses discussion xblocks (Default for openedx) whereas new discussion provider uses discussion sidebar (Default for 2U).

You can use app-learning MFE to view discussion xblocks

  • Create a course
  • Add a discussion xblock
  • Publish it
  • View in app-learning MFE. It will result in Error: This discussion could not be loaded. Refresh the page and try again.

@Ali-Salman29 Ali-Salman29 self-assigned this Jan 20, 2025
@Ali-Salman29
Copy link
Contributor

Thank You for providing the details. I'll look into this and get back to you as soon as possible.

@Ali-Salman29
Copy link
Contributor

https://github.com/openedx-unsupported/xblock-discussion
The Xblock is unsupported and there are some confits when I am installing it with the latest version of the openedX. Could you please share the version of the XBlock you are using?

@muhammadadeeltajamul
Copy link
Author

This is the setup I am using

  • Create a new course
  • Create section, sub-section and unit
  • Add a new discussion component
  • Set start date of course
  • Publish course
  • Open the course in app-learning
  • This error will be visible

@Ali-Salman29
Copy link
Contributor

The xblock is not compatible with the newer version. Can you please mention the openedX version that is compatible with this xblock?

@AhtishamShahid
Copy link

I don't think there is a need to install that xblock from the repo mentioned above, it is already available in devstack by default.

Image

@Ali-Salman29
Copy link
Contributor

Could you please confirm which version of the devstack (openedX release) you are using?

@AhtishamShahid
Copy link

@Ali-Salman29
Please try the master branch of this fork https://github.com/edx/devstack

@ormsbee
Copy link

ormsbee commented Feb 3, 2025

When you've figured out the right set of waffle flags to toggle to get old discussion blocks to display, could you please record them in this ticket?

Thank you.

@AhtishamShahid
Copy link

Hi, @ormsbee no flags are required for using xblock in the new installation please use this fork for devstack
Make sure ENABLE_NEW_STRUCTURE_DISCUSSIONS is disabled before course creation its default value is alreadyFalse.

@regisb
Copy link
Contributor

regisb commented Feb 11, 2025

Can someone please explain why the forum v2 API is not compatible with this "old" discussion xblock? (whatever it is) Which part of the forum v2 API is not backward-compatible? Is it because of one of the limitations listed in this document?

@AhtishamShahid
Copy link

Hi, @regisb have you tested xblock with forum v2 with mondgo? and limitations listed in the provided document do not include anything about old discussions view and xblock , our assumption is forum v2 is drop-in replacement for cs_comment_service and all of the stuff that was working with cs_commet service should work with forum v2.

Our initial testing on local devstack indicates that thread APIs in forum v2 are not 1:1 replacements for APIs in cs_comment service, Some params that are being used by xblock are not implemented in forum v2 .

If you need any help in reproducing this issue please let me know.

@AhtishamShahid
Copy link

Here is stack trace for this issue

edx.devstack.lms  | Traceback (most recent call last):
edx.devstack.lms  |   File "/edx/app/edxapp/venvs/edxapp/lib/python3.11/site-packages/django/core/handlers/exception.py", line 55, in inner
edx.devstack.lms  |     response = get_response(request)
edx.devstack.lms  |                ^^^^^^^^^^^^^^^^^^^^^
edx.devstack.lms  |   File "/edx/app/edxapp/venvs/edxapp/lib/python3.11/site-packages/django/core/handlers/base.py", line 197, in _get_response
edx.devstack.lms  |     response = wrapped_callback(request, *callback_args, **callback_kwargs)
edx.devstack.lms  |                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
edx.devstack.lms  |   File "/usr/lib/python3.11/contextlib.py", line 81, in inner
edx.devstack.lms  |     return func(*args, **kwds)
edx.devstack.lms  |            ^^^^^^^^^^^^^^^^^^^
edx.devstack.lms  |   File "/edx/app/edxapp/venvs/edxapp/lib/python3.11/site-packages/django/views/decorators/cache.py", line 40, in _cache_controlled
edx.devstack.lms  |     response = viewfunc(request, *args, **kw)
edx.devstack.lms  |                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
edx.devstack.lms  |   File "/edx/app/edxapp/venvs/edxapp/lib/python3.11/site-packages/django/contrib/auth/decorators.py", line 23, in _wrapper_view
edx.devstack.lms  |     return view_func(request, *args, **kwargs)
edx.devstack.lms  |            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
edx.devstack.lms  |   File "/edx/app/edxapp/edx-platform/lms/djangoapps/discussion/views.py", line 208, in wrapped_view
edx.devstack.lms  |     return view_func(request, course_key, *args, **kwargs)
edx.devstack.lms  |            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
edx.devstack.lms  |   File "/edx/app/edxapp/edx-platform/lms/djangoapps/discussion/views.py", line 326, in forum_form_discussion
edx.devstack.lms  |     return tab_view.get(request, course_id, 'discussion')
edx.devstack.lms  |            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
edx.devstack.lms  |   File "/edx/app/edxapp/venvs/edxapp/lib/python3.11/site-packages/django/utils/decorators.py", line 46, in _wrapper
edx.devstack.lms  |     return bound_method(*args, **kwargs)
edx.devstack.lms  |            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
edx.devstack.lms  |   File "/edx/app/edxapp/venvs/edxapp/lib/python3.11/site-packages/django/utils/decorators.py", line 134, in _wrapper_view
edx.devstack.lms  |     response = view_func(request, *args, **kwargs)
edx.devstack.lms  |                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
edx.devstack.lms  |   File "/edx/app/edxapp/venvs/edxapp/lib/python3.11/site-packages/django/utils/decorators.py", line 46, in _wrapper
edx.devstack.lms  |     return bound_method(*args, **kwargs)
edx.devstack.lms  |            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
edx.devstack.lms  |   File "/edx/app/edxapp/edx-platform/common/djangoapps/util/views.py", line 43, in inner
edx.devstack.lms  |     response = view_func(request, *args, **kwargs)
edx.devstack.lms  |                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
edx.devstack.lms  |   File "/edx/app/edxapp/venvs/edxapp/lib/python3.11/site-packages/django/utils/decorators.py", line 46, in _wrapper
edx.devstack.lms  |     return bound_method(*args, **kwargs)
edx.devstack.lms  |            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
edx.devstack.lms  |   File "/edx/app/edxapp/edx-platform/openedx/features/enterprise_support/api.py", line 367, in inner
edx.devstack.lms  |     return view_func(request, course_id, *args, **kwargs)
edx.devstack.lms  |            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
edx.devstack.lms  |   File "/edx/app/edxapp/edx-platform/lms/djangoapps/courseware/views/views.py", line 536, in get
edx.devstack.lms  |     return CourseTabView.handle_exceptions(request, course_key, course, exception)
edx.devstack.lms  |            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
edx.devstack.lms  |   File "/edx/app/edxapp/edx-platform/lms/djangoapps/courseware/views/views.py", line 534, in get
edx.devstack.lms  |     return super().get(request, course=course, page_context=page_context, **kwargs)
edx.devstack.lms  |            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
edx.devstack.lms  |   File "/edx/app/edxapp/venvs/edxapp/lib/python3.11/site-packages/web_fragments/views.py", line 23, in get
edx.devstack.lms  |     fragment = self.render_to_fragment(request, **kwargs)
edx.devstack.lms  |                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
edx.devstack.lms  |   File "/edx/app/edxapp/edx-platform/lms/djangoapps/courseware/views/views.py", line 688, in render_to_fragment
edx.devstack.lms  |     return tab.render_to_fragment(request, course, **kwargs)
edx.devstack.lms  |            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
edx.devstack.lms  |   File "/edx/app/edxapp/edx-platform/xmodule/tabs.py", line 291, in render_to_fragment
edx.devstack.lms  |     return self.fragment_view.render_to_fragment(request, course_id=str(course.id), **kwargs)
edx.devstack.lms  |            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
edx.devstack.lms  |   File "/edx/app/edxapp/edx-platform/lms/djangoapps/discussion/views.py", line 827, in render_to_fragment
edx.devstack.lms  |     context = _create_discussion_board_context(request, base_context, thread=thread)
edx.devstack.lms  |               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
edx.devstack.lms  |   File "/edx/app/edxapp/edx-platform/lms/djangoapps/discussion/views.py", line 529, in _create_discussion_board_context
edx.devstack.lms  |     threads, query_params = get_threads(request, course, user_info)   # This might process a search query
edx.devstack.lms  |                             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
edx.devstack.lms  |   File "/edx/app/edxapp/edx-platform/lms/djangoapps/discussion/views.py", line 172, in get_threads
edx.devstack.lms  |     paginated_results = cc.Thread.search(query_params)
edx.devstack.lms  |                         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
edx.devstack.lms  |   File "/edx/app/edxapp/edx-platform/openedx/core/djangoapps/django_comment_common/comment_client/thread.py", line 83, in search
edx.devstack.lms  |     response = forum_api.get_user_threads(**params)
edx.devstack.lms  |                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
edx.devstack.lms  | TypeError: get_user_threads() got an unexpected keyword argument 'context'

@regisb
Copy link
Contributor

regisb commented Feb 12, 2025

This is very helpful information, thank you Ahtisham. This stacktrace highlights the fact that the problem does not lie with an API incompatibility. Instead, it seems that it's just a matter of calling the API with too many arguments. This used to be OK with the HTTP API, because unnecessary arguments were just being silently swallowed. But with this native Python API, unused arguments trigger a TypeError.

There might be further issues down the road, but I'm confident that this specific one can be resolved quite easily.

taimoor-ahmed-1 pushed a commit that referenced this issue Feb 12, 2025
The get_user_threads api was not accepting additional arguments and there the discussion xblock wasn't working with the forum service. This PR adds args and kwargs params to the api to avoid breakage.
close #149
taimoor-ahmed-1 pushed a commit that referenced this issue Feb 12, 2025
The get_user_threads api was not accepting additional arguments and there the discussion xblock wasn't working with the forum service. This PR adds args and kwargs params to the api to avoid breakage.
close #149
@taimoor-ahmed-1 taimoor-ahmed-1 linked a pull request Feb 12, 2025 that will close this issue
taimoor-ahmed-1 pushed a commit that referenced this issue Feb 12, 2025
The get_user_threads api was not accepting additional arguments and there the discussion xblock wasn't working with the forum service. This PR adds args and kwargs params to the api to avoid breakage.
close #149
@regisb
Copy link
Contributor

regisb commented Feb 12, 2025

@AhtishamShahid can you please try out the following fix? #160

@taimoor-ahmed-1 taimoor-ahmed-1 self-assigned this Feb 12, 2025
@muhammadadeeltajamul
Copy link
Author

edx.devstack.lms  | Traceback (most recent call last):
edx.devstack.lms  |   File "/edx/app/edxapp/venvs/edxapp/lib/python3.11/site-packages/django/core/handlers/exception.py", line 55, in inner
edx.devstack.lms  |     response = get_response(request)
edx.devstack.lms  |                ^^^^^^^^^^^^^^^^^^^^^
edx.devstack.lms  |   File "/edx/app/edxapp/venvs/edxapp/lib/python3.11/site-packages/django/core/handlers/base.py", line 197, in _get_response
edx.devstack.lms  |     response = wrapped_callback(request, *callback_args, **callback_kwargs)
edx.devstack.lms  |                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
edx.devstack.lms  |   File "/usr/lib/python3.11/contextlib.py", line 81, in inner
edx.devstack.lms  |     return func(*args, **kwds)
edx.devstack.lms  |            ^^^^^^^^^^^^^^^^^^^
edx.devstack.lms  |   File "/edx/app/edxapp/venvs/edxapp/lib/python3.11/site-packages/django/views/decorators/cache.py", line 40, in _cache_controlled
edx.devstack.lms  |     response = viewfunc(request, *args, **kw)
edx.devstack.lms  |                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
edx.devstack.lms  |   File "/edx/app/edxapp/venvs/edxapp/lib/python3.11/site-packages/django/contrib/auth/decorators.py", line 23, in _wrapper_view
edx.devstack.lms  |     return view_func(request, *args, **kwargs)
edx.devstack.lms  |            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
edx.devstack.lms  |   File "/edx/app/edxapp/edx-platform/lms/djangoapps/discussion/views.py", line 208, in wrapped_view
edx.devstack.lms  |     return view_func(request, course_key, *args, **kwargs)
edx.devstack.lms  |            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
edx.devstack.lms  |   File "/edx/app/edxapp/edx-platform/lms/djangoapps/discussion/views.py", line 326, in forum_form_discussion
edx.devstack.lms  |     return tab_view.get(request, course_id, 'discussion')
edx.devstack.lms  |            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
edx.devstack.lms  |   File "/edx/app/edxapp/venvs/edxapp/lib/python3.11/site-packages/django/utils/decorators.py", line 46, in _wrapper
edx.devstack.lms  |     return bound_method(*args, **kwargs)
edx.devstack.lms  |            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
edx.devstack.lms  |   File "/edx/app/edxapp/venvs/edxapp/lib/python3.11/site-packages/django/utils/decorators.py", line 134, in _wrapper_view
edx.devstack.lms  |     response = view_func(request, *args, **kwargs)
edx.devstack.lms  |                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
edx.devstack.lms  |   File "/edx/app/edxapp/venvs/edxapp/lib/python3.11/site-packages/django/utils/decorators.py", line 46, in _wrapper
edx.devstack.lms  |     return bound_method(*args, **kwargs)
edx.devstack.lms  |            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
edx.devstack.lms  |   File "/edx/app/edxapp/edx-platform/common/djangoapps/util/views.py", line 43, in inner
edx.devstack.lms  |     response = view_func(request, *args, **kwargs)
edx.devstack.lms  |                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
edx.devstack.lms  |   File "/edx/app/edxapp/venvs/edxapp/lib/python3.11/site-packages/django/utils/decorators.py", line 46, in _wrapper
edx.devstack.lms  |     return bound_method(*args, **kwargs)
edx.devstack.lms  |            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
edx.devstack.lms  |   File "/edx/app/edxapp/edx-platform/openedx/features/enterprise_support/api.py", line 367, in inner
edx.devstack.lms  |     return view_func(request, course_id, *args, **kwargs)
edx.devstack.lms  |            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
edx.devstack.lms  |   File "/edx/app/edxapp/edx-platform/lms/djangoapps/courseware/views/views.py", line 536, in get
edx.devstack.lms  |     return CourseTabView.handle_exceptions(request, course_key, course, exception)
edx.devstack.lms  |            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
edx.devstack.lms  |   File "/edx/app/edxapp/edx-platform/lms/djangoapps/courseware/views/views.py", line 534, in get
edx.devstack.lms  |     return super().get(request, course=course, page_context=page_context, **kwargs)
edx.devstack.lms  |            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
edx.devstack.lms  |   File "/edx/app/edxapp/venvs/edxapp/lib/python3.11/site-packages/web_fragments/views.py", line 23, in get
edx.devstack.lms  |     fragment = self.render_to_fragment(request, **kwargs)
edx.devstack.lms  |                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
edx.devstack.lms  |   File "/edx/app/edxapp/edx-platform/lms/djangoapps/courseware/views/views.py", line 688, in render_to_fragment
edx.devstack.lms  |     return tab.render_to_fragment(request, course, **kwargs)
edx.devstack.lms  |            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
edx.devstack.lms  |   File "/edx/app/edxapp/edx-platform/xmodule/tabs.py", line 291, in render_to_fragment
edx.devstack.lms  |     return self.fragment_view.render_to_fragment(request, course_id=str(course.id), **kwargs)
edx.devstack.lms  |            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
edx.devstack.lms  |   File "/edx/app/edxapp/edx-platform/lms/djangoapps/discussion/views.py", line 827, in render_to_fragment
edx.devstack.lms  |     context = _create_discussion_board_context(request, base_context, thread=thread)
edx.devstack.lms  |               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
edx.devstack.lms  |   File "/edx/app/edxapp/edx-platform/lms/djangoapps/discussion/views.py", line 529, in _create_discussion_board_context
edx.devstack.lms  |     threads, query_params = get_threads(request, course, user_info)   # This might process a search query
edx.devstack.lms  |                             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
edx.devstack.lms  |   File "/edx/app/edxapp/edx-platform/lms/djangoapps/discussion/views.py", line 172, in get_threads
edx.devstack.lms  |     paginated_results = cc.Thread.search(query_params)
edx.devstack.lms  |                         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
edx.devstack.lms  |   File "/edx/app/edxapp/edx-platform/openedx/core/djangoapps/django_comment_common/comment_client/thread.py", line 83, in search
edx.devstack.lms  |     response = forum_api.get_user_threads(**params)
edx.devstack.lms  |                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
edx.devstack.lms  |   File "/edx/app/edxapp/venvs/edxapp/lib/python3.11/site-packages/forum/api/threads.py", line 387, in get_user_threads
edx.devstack.lms  |     backend.validate_params(params)
edx.devstack.lms  |   File "/edx/app/edxapp/venvs/edxapp/lib/python3.11/site-packages/forum/backends/mongodb/api.py", line 955, in validate_params
edx.devstack.lms  |     raise ForumV2RequestError("User doesn't exist")
edx.devstack.lms  | forum.utils.ForumV2RequestError: User doesn't exist

@AhtishamShahid
Copy link

Steps to render discussions xblock and reproduce this error.

  1. Disable discussions.enable_new_structure_discussions waffle flag.
  2. Create a new course.
  3. In studio create section -> subsection -> unit.
  4. Click on the discussion button new block will be added to the unit, click on publish.
  5. Go to learning MFE and open this unit.
  6. Observe if block is rendered properly.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Report of or fix for something that isn't working as intended release blocker Blocks the upcoming release (fix needed)
Projects
Status: Backlog
Development

Successfully merging a pull request may close this issue.

6 participants