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

fix: return empty list when no courses are found for request #35942

Merged
merged 6 commits into from
Dec 5, 2024

Conversation

mariajgrimaldi
Copy link
Member

@mariajgrimaldi mariajgrimaldi commented Dec 2, 2024

Description

This PR addresses an issue reported while testing Sumac, where the API V2 is on by default in the authoring MFE: openedx/wg-build-test-release#428. It fails when retrieving an empty list of courses with the queryparams api/contentstore/v2/home/courses?page=1&order=display_name. When this was implemented, the course authoring MFE rendered the empty lists only with page=1 query param (didn't do any filtering/ordering by default), which was later changed to page=1&order=display_name which now ordered by default.

This issue occurs because all the filtering and ordering are done under the assumption that course_overviews is always a query set. However, that's only true when there are courses available and CourseOverview.get_all_courses is used. When not, an empty list is returned instead, raising a 500 error in Studio.

cms-1  |   File "/openedx/edx-platform/cms/djangoapps/contentstore/views/course.py", line 485, in get_filtered_and_ordered_courses
cms-1  |     course_overviews = get_courses_order_by(order, course_overviews)
cms-1  |                        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
cms-1  |   File "/openedx/edx-platform/cms/djangoapps/contentstore/views/course.py", line 627, in get_courses_order_by
cms-1  |     return course_overviews.order_by(order_query)
cms-1  |            ^^^^^^^^^^^^^^^^^^^^^^^^^
cms-1  | AttributeError: 'list' object has no attribute 'order_by'

Supporting information

openedx/wg-build-test-release#428
This feature was initially introduced here: #34173

Testing instructions

  1. Sign up to studio as a new user
  2. Try entering the Studio Home - no error should be raised
  3. Ask for course creator permissions
  4. Create a few courses
  5. Filter them using the search bar or the filters available

Deadline

Before Thursday Dec 5.

The next step for this feature is the deprecation of Course Home API V1.

@openedx-webhooks openedx-webhooks added the open-source-contribution PR author is not from Axim or 2U label Dec 2, 2024
@openedx-webhooks
Copy link

openedx-webhooks commented Dec 2, 2024

Thanks for the pull request, @mariajgrimaldi!

What's next?

Please work through the following steps to get your changes ready for engineering review:

🔘 Get product approval

If you haven't already, check this list to see if your contribution needs to go through the product review process.

  • If it does, you'll need to submit a product proposal for your contribution, and have it reviewed by the Product Working Group.
    • This process (including the steps you'll need to take) is documented here.
  • If it doesn't, simply proceed with the next step.

🔘 Provide context

To help your reviewers and other members of the community understand the purpose and larger context of your changes, feel free to add as much of the following information to the PR description as you can:

  • Dependencies

    This PR must be merged before / after / at the same time as ...

  • Blockers

    This PR is waiting for OEP-1234 to be accepted.

  • Timeline information

    This PR must be merged by XX date because ...

  • Partner information

    This is for a course on edx.org.

  • Supporting documentation
  • Relevant Open edX discussion forum threads

🔘 Get a green build

If one or more checks are failing, continue working on your changes until this is no longer the case and your build turns green.

🔘 Let us know that your PR is ready for review:

Who will review my changes?

This repository is currently maintained by @openedx/wg-maintenance-edx-platform. Tag them in a comment and let them know that your changes are ready for review.

Where can I find more information?

If you'd like to get more details on all aspects of the review process for open source pull requests (OSPRs), check out the following resources:

When can I expect my changes to be merged?

Our goal is to get community contributions seen and reviewed as efficiently as possible.

However, the amount of time that it takes to review and merge a PR can vary significantly based on factors such as:

  • The size and impact of the changes that it introduces
  • The need for product review
  • Maintenance status of the parent repository

💡 As a result it may take up to several weeks or months to complete a review and merge your PR.

@mariajgrimaldi mariajgrimaldi force-pushed the MJG/return-empty-course-list branch from 6b687c6 to 6cccb83 Compare December 2, 2024 19:35
@mariajgrimaldi mariajgrimaldi marked this pull request as ready for review December 2, 2024 19:36
@mariajgrimaldi mariajgrimaldi marked this pull request as draft December 2, 2024 20:45
Comment on lines +578 to +582
else:
# If no course keys are found for the current user, then return without filtering
# or ordering the courses list.
return courses_list, []
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@mariajgrimaldi mariajgrimaldi force-pushed the MJG/return-empty-course-list branch from f58fd2f to faf99a5 Compare December 3, 2024 10:35
@mariajgrimaldi mariajgrimaldi marked this pull request as ready for review December 3, 2024 11:49
@mariajgrimaldi
Copy link
Member Author

mariajgrimaldi commented Dec 3, 2024

Hey @felipemontoya, just giving you a heads-up that this issue related to #34173 came up during Sumac testing.

Copy link
Member

@felipemontoya felipemontoya left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The changes looks completely reasonable. It is now complaining about the branch not being up to date, but other than that it looks good to merge

@mariajgrimaldi
Copy link
Member Author

See the discussion here: #35912 (comment)

@mariajgrimaldi mariajgrimaldi force-pushed the MJG/return-empty-course-list branch from 1a903cb to 5461fa1 Compare December 4, 2024 12:27
@mariajgrimaldi mariajgrimaldi force-pushed the MJG/return-empty-course-list branch from 5461fa1 to cf265ed Compare December 4, 2024 12:54
@Ali-Salman29
Copy link
Contributor

The changes look good to me.

@mariajgrimaldi
Copy link
Member Author

@felipemontoya: could you re-review the PR? As a result of this discussion, I added type hints to the ordering/filtering function to be more explicit about the types they handle.

Copy link
Member

@felipemontoya felipemontoya left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

@mariajgrimaldi mariajgrimaldi merged commit 1c835eb into master Dec 5, 2024
51 checks passed
@mariajgrimaldi mariajgrimaldi deleted the MJG/return-empty-course-list branch December 5, 2024 14:53
@mariajgrimaldi
Copy link
Member Author

@Ali-Salman29 @felipemontoya: merged! Thank you for all the help.

@edx-pipeline-bot
Copy link
Contributor

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

mariajgrimaldi added a commit that referenced this pull request Dec 5, 2024
This change addresses an issue reported while testing Sumac, where the API V2 is on by default in the authoring MFE: openedx/wg-build-test-release#428. It fails when retrieving an empty list of courses with the queryparams api/contentstore/v2/home/courses?page=1&order=display_name. When this was implemented, the course authoring MFE rendered the empty lists only with page=1 query param (didn't do any filtering/ordering by default), which was later changed to page=1&order=display_name which now ordered by default.

This issue occurs because all the filtering and ordering are done under the assumption that course_overviews is always a query set. However, that's only true when there are courses available and CourseOverview.get_all_courses is used. When not, an empty list is returned instead, raising a 500 error in Studio.
mariajgrimaldi added a commit that referenced this pull request Dec 5, 2024
This change addresses an issue reported while testing Sumac, where the API V2 is on by default in the authoring MFE: openedx/wg-build-test-release#428. It fails when retrieving an empty list of courses with the queryparams api/contentstore/v2/home/courses?page=1&order=display_name. When this was implemented, the course authoring MFE rendered the empty lists only with page=1 query param (didn't do any filtering/ordering by default), which was later changed to page=1&order=display_name which now ordered by default.

This issue occurs because all the filtering and ordering are done under the assumption that course_overviews is always a query set. However, that's only true when there are courses available and CourseOverview.get_all_courses is used. When not, an empty list is returned instead, raising a 500 error in Studio.
@edx-pipeline-bot
Copy link
Contributor

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

1 similar comment
@edx-pipeline-bot
Copy link
Contributor

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

@edx-pipeline-bot
Copy link
Contributor

2U Release Notice: This PR has been rolled back from the edX production environment.

1 similar comment
@edx-pipeline-bot
Copy link
Contributor

2U Release Notice: This PR has been rolled back from the edX production environment.

@edx-pipeline-bot
Copy link
Contributor

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

1 similar comment
@edx-pipeline-bot
Copy link
Contributor

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

farhaanbukhsh pushed a commit that referenced this pull request Dec 9, 2024
This change addresses an issue reported while testing Sumac, where the API V2 is on by default in the authoring MFE: openedx/wg-build-test-release#428. It fails when retrieving an empty list of courses with the queryparams api/contentstore/v2/home/courses?page=1&order=display_name. When this was implemented, the course authoring MFE rendered the empty lists only with page=1 query param (didn't do any filtering/ordering by default), which was later changed to page=1&order=display_name which now ordered by default.

This issue occurs because all the filtering and ordering are done under the assumption that course_overviews is always a query set. However, that's only true when there are courses available and CourseOverview.get_all_courses is used. When not, an empty list is returned instead, raising a 500 error in Studio.
@feanil feanil mentioned this pull request Dec 10, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
open-source-contribution PR author is not from Axim or 2U
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

[Test failure] < TC_AUTHOR_146 >: Cannot request course creator permission
5 participants