edx-platform icon indicating copy to clipboard operation
edx-platform copied to clipboard

fix: Course blocks API with param return_type=list

Open qasimgulzar opened this issue 1 year ago • 5 comments

Discussion: edx (New). Issue Link Endpoint: {LMS_HOST}/api/courses/v1/blocks/?course_id={COURSE_ID}&return_type=list

Root cause When return_type is set to list in querystring the api endpoint is crashing because it is calling dict method on ReturnList type instance to get blocks.

Solution I have added a type check before fetching blocks if it is getting ReturnList I am treating it as list. otherwise following the old path.

Stacktrace

File "/opened/venv/lib/python3.8/site-packages/django/core/handlers/exception.py", line 55, in inner
response = get_response (request)
File "/openedx/venv/lib/python3.8/site-packages/django/core/handlers/base.py",line 197, in _get_response
response = wrapped_callback(request,
*callback_args,
**callback_kwargs)
File "/opened/venv/lib/python3.8/site-packages/django/views/decorators/csrf.py",line 56, in wrapper_view return view_func(*args,
**kwargs)
File "/opened/venv/lib/python3.8/site-packages/django/views/generic/base.py",line 104, in view return self.dispatch(request, *args,
**kwargs)
File "/opened/venv/lib/python3.8/site-packages/django/utils/decorators.py",line46,in_wrapper return bound_method(*args
**kwargs)
File "/opened×/venv/lib/python3.8/site-packages/rest_framework/views.py", line 509, in dispatch
response = self. handle_exception (exc)
File "/opened/venv/lib/python3.8/site-packages/rest_framework/views.py",line 506, in dispatch
response = handler(request, *args, **kwargs)
File "/opened/venv/lib/python3.8/site-packages/rest_framework/generics.py", line 199, in get return self.list(request, *args, **kwargs)
File "/opened×/edx-platform/./lms/djangoapps/course_api/blocks/views.py", line 315, in list
response = filter_discussion_blocks_from_response(response,
course_key)
File "/opened/edx-platform/./lms/djangoapps/course_api/blocks/utils.py",line19,infilter_discussion_xblocks_from_response key for key, value in response.data.get('blocks' {}).items()
AttributeError:
'ReturnList' object has no attribute
'get'

qasimgulzar avatar Mar 26 '24 09:03 qasimgulzar

Thanks for the pull request, @qasimgulzar! Please note that it may take us up to several weeks or months to complete a review and merge your PR.

Feel free to add as much of the following information to the ticket as you can:

  • supporting documentation
  • Open edX discussion forum threads
  • timeline information ("this must be merged by XX date", and why that is)
  • partner information ("this is a course on edx.org")
  • any other information that can help Product understand the context for the PR

All technical communication about the code itself will be done via the GitHub pull request interface. As a reminder, our process documentation is here.

Please let us know once your PR is ready for our review and all tests are green.

openedx-webhooks avatar Mar 26 '24 09:03 openedx-webhooks

This PR is now ready for review. Cc @vunguyen-dmt who reported the initial issue https://github.com/openedx/edx-platform/issues/34379

regisb avatar Mar 28 '24 13:03 regisb

@openedx/2u-aperture could you please help reviewing this PR?

qasimgulzar avatar Apr 01 '24 06:04 qasimgulzar

Hi @qasimgulzar,

This particular bit of code lies outside of Aperture's ownership/maintenance load, nor does the team have any experience or knowledge of the functionality in the course_api app. I'm afraid we're probably not the best team positioned to help here.

I believe you might be looking for folks from the Aurora team at 2U, who look to be maintainers of this functionality (sorry for any confusion!)

justinhynes avatar Apr 02 '24 12:04 justinhynes

@justinhynes thank you very much for you response, let me try to find someone relevant to this PR. I apologise to bother you :)

qasimgulzar avatar Apr 02 '24 12:04 qasimgulzar

@qasimgulzar 🎉 Your pull request was merged! Please take a moment to answer a two question survey so we can improve your experience in the future.

openedx-webhooks avatar May 10 '24 17:05 openedx-webhooks

2U Release Notice: This PR has been deployed to the edX staging environment in preparation for a release to production.

edx-pipeline-bot avatar May 10 '24 18:05 edx-pipeline-bot

2U Release Notice: This PR has been deployed to the edX production environment.

edx-pipeline-bot avatar May 10 '24 19:05 edx-pipeline-bot