Skip to content

fix: avoid anonymous completion lookup in navigation#38024

Open
meet0208 wants to merge 2 commits intoopenedx:masterfrom
Abstract-Tech:meet/fix_course-outline
Open

fix: avoid anonymous completion lookup in navigation#38024
meet0208 wants to merge 2 commits intoopenedx:masterfrom
Abstract-Tech:meet/fix_course-outline

Conversation

@meet0208
Copy link

Description

This PR fixes course outline loading for anonymous users in the Learning MFE by preventing a server error in the course navigation API.

Previously, anonymous requests to GET /api/course_home/v1/navigation/{course_key} could raise a 500 when completion data was queried with AnonymousUser. This caused the course outline sidebar to fail to render for logged-out users, even when course visibility and waffle settings allowed public access.

This change adds an anonymous-user guard in CourseNavigationBlocksView.completions_dict:

  • If request.user is anonymous, return an empty completion map ({}).
  • Keep existing outline access filtering logic (filter_inaccessible_blocks) unchanged to preserve access control.

Implications

  • Anonymous users now receive a valid navigation payload instead of a 500.
  • Visibility/access restrictions continue to be enforced by existing processors and filtering.
  • No behavior change for authenticated learners/staff.

Supporting information

Relevant code / endpoint

  • File: lms/djangoapps/course_home_api/outline/views.py
  • Endpoint: GET /api/course_home/v1/navigation/{course_key}
  • Root cause: completion lookup attempted for AnonymousUser

Configuration context (unchanged)

  • seo.enable_anonymous_courseware_access enabled
  • Course visibility set to public or public_outline

Testing instructions

  1. Ensure the course is configured with:

    • visibility set to public (or public_outline)
    • waffle flag seo.enable_anonymous_courseware_access enabled
  2. Open the courseware URL in an incognito / logged-out browser session.

  3. Confirm GET /api/course_home/v1/navigation/{course_key} returns 200 (not 500).

  4. Verify the outline sidebar renders in the Learning MFE.

  5. Log in as a learner and as staff/admin and confirm outline behavior is unchanged.

  6. Optional regression checks:

    • Confirm hidden/inaccessible content remains filtered as before.
    • Confirm no new traceback appears in LMS logs for anonymous navigation requests.

Deadline

None.

Other information

User roles impacted

  • Learner: Yes (logged-out / public access flow)
  • Course Author: No direct impact
  • Developer: Yes (API behavior and debugging flow)
  • Operator: Yes (reduced 500s in logs for anonymous navigation requests)

UI changes

  • UI impact: course outline now renders for anonymous users on eligible public / public_outline courses.

  • Suggested screenshots to attach:

    1. Before: anonymous courseware page with missing/empty outline + API 500
    2. After: anonymous courseware page with outline visible + API 200
    3. Network tab response for /api/course_home/v1/navigation/{course_key} (before vs after)

Configuration changes

  • None.

Dependencies / special concerns

  • No dependency on other PRs.
  • No deprecations or migrations.
  • Security/access control is unchanged (no relaxation of access restrictions); this only prevents anonymous completion lookup failures.
  • No API contract changes.

… outline.

Return empty completions_dict for AnonymousUser in CourseNavigationBlocksView to prevent 500 on /api/course_home/v1/navigation/{course_key} for public anonymous access. Keeps existing outline access filtering unchanged.
@openedx-webhooks
Copy link

openedx-webhooks commented Feb 19, 2026

Thanks for the pull request, @meet0208!

This repository is currently maintained by @openedx/wg-maintenance-openedx-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 Feb 19, 2026
@github-project-automation github-project-automation bot moved this to Needs Triage in Contributions Feb 19, 2026
@mphilbrick211 mphilbrick211 added the needs test run Author's first PR to this repository, awaiting test authorization from Axim label Feb 24, 2026
@mphilbrick211 mphilbrick211 moved this from Needs Triage to Needs Tests Run or CLA Signed in Contributions Feb 24, 2026
@mphilbrick211
Copy link

Hi @meet0208! Thank you for this contribution!

It looks like you're contributing on behalf of an organization. If so, could you please have your manager reach out to oscm@axim.org to have you added to our existing entity agreement? That way, we can get your CLA check to turn green.

@e0d
Copy link
Contributor

e0d commented Feb 25, 2026

@meet0208 you've been added to the entity CLA and that should be reflected in GitHub this evening.

@e0d e0d removed the needs test run Author's first PR to this repository, awaiting test authorization from Axim label Feb 25, 2026
@meet0208
Copy link
Author

meet0208 commented Feb 26, 2026

@e0d or @mphilbrick211 Hey can you approve a re run for this PR.

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: Needs Tests Run or CLA Signed

Development

Successfully merging this pull request may close these issues.

4 participants