Skip to content

fix: remove incorrect key type when filtering inaccessible blocks - #35542

Merged
farhaanbukhsh merged 1 commit into
openedx:masterfrom
open-craft:agrendalath/fix-incorrect-key-type-upstream
Jan 23, 2025
Merged

fix: remove incorrect key type when filtering inaccessible blocks#35542
farhaanbukhsh merged 1 commit into
openedx:masterfrom
open-craft:agrendalath/fix-incorrect-key-type-upstream

Conversation

@Agrendalath

@Agrendalath Agrendalath commented Sep 25, 2024

Copy link
Copy Markdown
Member

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-8469 (temporary)

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

openedx-webhooks commented Sep 25, 2024

Copy link
Copy Markdown

Thanks for the pull request, @Agrendalath!

This repository is currently maintained by @openedx/wg-maintenance-edx-platform.

Once you've gone through the following steps feel free to tag them in a comment and let them know that your changes are 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.

Details

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
Copy Markdown

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
Copy Markdown
Member Author

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

@mphilbrick211

Copy link
Copy Markdown

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

@Agrendalath checking back in on this!

@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
Copy Markdown
Member Author

@mphilbrick211, this is ready for review.

@mphilbrick211 mphilbrick211 added the needs reviewer assigned PR needs to be (re-)assigned a new reviewer label Dec 17, 2024
@Agrendalath
Agrendalath force-pushed the agrendalath/fix-incorrect-key-type-upstream branch from 40510c2 to abea6dc Compare January 6, 2025 22:39
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 abea6dc to 381242c Compare January 20, 2025 19:53

@farhaanbukhsh farhaanbukhsh left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

👍

  • ✅ I tested this on Tutor devstack and it helps to handle the error gracefully.
  • ✅ I read through the code
  • ❌ I checked for accessibility issues
  • ❌ Includes documentation

@farhaanbukhsh
farhaanbukhsh merged commit 8b7a771 into openedx:master Jan 23, 2025
@farhaanbukhsh
farhaanbukhsh deleted the agrendalath/fix-incorrect-key-type-upstream branch January 23, 2025 12:23
@openedx-webhooks openedx-webhooks removed the needs reviewer assigned PR needs to be (re-)assigned a new reviewer label Jan 23, 2025
@edx-pipeline-bot

Copy link
Copy Markdown
Contributor

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

@edx-pipeline-bot

Copy link
Copy Markdown
Contributor

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

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

Archived in project

Development

Successfully merging this pull request may close these issues.

7 participants