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: remove incorrect key type when filtering inaccessible blocks #35542

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

Agrendalath
Copy link
Member

@Agrendalath Agrendalath commented Sep 25, 2024

Description

Returning the list with a 'completion' string was added in 9bc0f85. However, the get_accessible_sequences method expects a list of dicts with an 'id' key. When it gets the ['completion'], it fails with the following traceback:

Internal Server Error: /api/course_home/v1/navigation/course-v1:OpenedX+DemoX+DemoCourse
Traceback (most recent call last):
  File "/openedx/venv/lib/python3.11/site-packages/django/core/handlers/exception.py", line 55, in inner
    response = get_response(request)
               ^^^^^^^^^^^^^^^^^^^^^
  File "/openedx/venv/lib/python3.11/site-packages/django/core/handlers/base.py", line 197, in _get_response
    response = wrapped_callback(request, *callback_args, **callback_kwargs)
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/pyenv/versions/3.11.8/lib/python3.11/contextlib.py", line 81, in inner
    return func(*args, **kwds)
           ^^^^^^^^^^^^^^^^^^^
  File "/openedx/venv/lib/python3.11/site-packages/django/views/decorators/csrf.py", line 56, in wrapper_view
    return view_func(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/openedx/venv/lib/python3.11/site-packages/django/views/generic/base.py", line 104, in view
    return self.dispatch(request, *args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/openedx/venv/lib/python3.11/site-packages/rest_framework/views.py", line 509, in dispatch
    response = self.handle_exception(exc)
               ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/openedx/venv/lib/python3.11/site-packages/rest_framework/views.py", line 469, in handle_exception
    self.raise_uncaught_exception(exc)
  File "/openedx/venv/lib/python3.11/site-packages/rest_framework/views.py", line 480, in raise_uncaught_exception
    raise exc
  File "/openedx/venv/lib/python3.11/site-packages/rest_framework/views.py", line 506, in dispatch
    response = handler(request, *args, **kwargs)
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/openedx/edx-platform/lms/djangoapps/course_home_api/outline/views.py", line 478, in get
    course_blocks = self.filter_inaccessible_blocks(course_blocks, course_key)
                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/openedx/edx-platform/lms/djangoapps/course_home_api/outline/views.py", line 502, in filter_inaccessible_blocks
    section_data['children'] = self.get_accessible_sequences(
                               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/openedx/edx-platform/lms/djangoapps/course_home_api/outline/views.py", line 589, in get_accessible_sequences
    return [
           ^
  File "/openedx/edx-platform/lms/djangoapps/course_home_api/outline/views.py", line 591, in <listcomp>
    if seq_data['id'] in available_sequence_ids or seq_data['type'] != 'sequential'
       ~~~~~~~~^^^^^^
TypeError: string indices must be integers, not 'str'

Testing instructions

  1. Check that no tests are broken after this change.

Steps to reproduce this error

  1. Create the courseware.disable_navigation_sidebar_blocks_caching waffle flag and set it to Yes.
  2. Create a new empty section in an existing course.
  3. Visit the http://local.edly.io:8000/api/course_home/v1/navigation/course-v1:OpenedX+DemoX+DemoCourse endpoint (it should return HTTP 500) and check the LMS logs.

Private-ref: BB-8954

@Agrendalath Agrendalath self-assigned this Sep 25, 2024
@openedx-webhooks
Copy link

openedx-webhooks commented Sep 25, 2024

Thanks for the pull request, @Agrendalath!

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.

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

Hi @Agrendalath! Are you still planning to pursue this pull request?

@Agrendalath Agrendalath force-pushed the agrendalath/fix-incorrect-key-type-upstream branch from bd9dfeb to 194aa3f Compare October 29, 2024 23:12
@Agrendalath
Copy link
Member Author

@mphilbrick211, thanks for checking. I'll get back to this PR within the next two weeks.

@mphilbrick211
Copy link

@mphilbrick211, thanks for checking. I'll get back to this PR within the next two weeks.

@Agrendalath checking back in on this!

Returning the list with a 'completion' string was added in 9bc0f85. However,
the `get_accessible_sequences` method expects a list of dicts with an 'id' key.
@Agrendalath Agrendalath force-pushed the agrendalath/fix-incorrect-key-type-upstream branch from 194aa3f to 40510c2 Compare December 16, 2024 18:20
@Agrendalath Agrendalath marked this pull request as ready for review December 16, 2024 18:21
@Agrendalath
Copy link
Member Author

@mphilbrick211, this is ready for review.

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: Waiting on Author
Development

Successfully merging this pull request may close these issues.

3 participants