Skip to content

fix: sync block structure cache before building navigation sidebar#38812

Open
BryanttV wants to merge 1 commit into
openedx:masterfrom
eduNEXT:bav/fix-stale-navigation-sidebar-after-publish
Open

fix: sync block structure cache before building navigation sidebar#38812
BryanttV wants to merge 1 commit into
openedx:masterfrom
eduNEXT:bav/fix-stale-navigation-sidebar-after-publish

Conversation

@BryanttV

@BryanttV BryanttV commented Jun 24, 2026

Copy link
Copy Markdown
Contributor

Description

This PR fixes stale content in the Learning MFE left navigation sidebar after course publish (e.g., content group visibility changes in Studio OR updates in the block names).

On sidebar cache miss, synchronously refresh the block structure cache before building the outline tree, so the sidebar is not populated from outdated block structure data while the async Celery task is still pending.

Problem

After publishing course changes in Studio, the Learning MFE sidebar (GET /api/course_home/v1/navigation/{course_key}) can show outdated blocks for up to one hour.

Root cause

The navigation endpoint caches the intermediate outline tree for one hour, keyed in part by course_version (the published structure version_guid).

When a course is published:

  1. course_version changes > sidebar cache miss (new cache key).
  2. The view rebuilds the tree via get_course_outline_block_tree > get_blocks > get_collected().
  3. get_collected() can return stale block structure from cache because it does not re-check freshness on a cache hit.
  4. Block structure is updated asynchronously by Celery (update_course_in_cache_v2), with a 30-second delay after course_published (BLOCK_STRUCTURES_SETTINGS['COURSE_PUBLISH_TASK_DELAY']).

If the sidebar is requested in that window, stale block structure is cached under the new course_version key for one hour, even though Celery later updates block structure correctly.

Solution

On sidebar cache miss, call update_course_in_cache(course_key) synchronously before building the outline tree. This uses the existing update_collected_if_needed() path, which refreshes the block structure only when it is outdated.

Supporting information

Testing instructions

Using Tutor local:

  1. From Studio, create a course and create two content groups (Content Group A and Content Group B).
  2. From the LMS, create 2 cohorts, each linked to a Content Group.
  3. Assign a user to a cohort.
  4. Create two or more units.
  5. Modify the visibility of the one unit so that it is restricted only to Content Group A.
  6. Modify the visibility of the other unit so that it is restricted only to Content Group B.
  7. Make changes by modifying the visibility of the units and immediately (before 30 seconds pass), as a student, verify that the sidebar is correctly updated.

Deadline

Verawood

@openedx-webhooks openedx-webhooks added open-source-contribution PR author is not from Axim or 2U core contributor PR author is a Core Contributor (who may or may not have write access to this repo). labels Jun 24, 2026
@openedx-webhooks

openedx-webhooks commented Jun 24, 2026

Copy link
Copy Markdown

Thanks for the pull request, @BryanttV!

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.

@BryanttV BryanttV force-pushed the bav/fix-stale-navigation-sidebar-after-publish branch from b1706db to 5b80802 Compare June 24, 2026 22:54
@mphilbrick211 mphilbrick211 moved this from Needs Triage to Ready for Review in Contributions Jun 25, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

core contributor PR author is a Core Contributor (who may or may not have write access to this repo). open-source-contribution PR author is not from Axim or 2U

Projects

Status: Ready for Review

Development

Successfully merging this pull request may close these issues.

3 participants