Skip to content

feat: display detailed error message for 403 catalog visibility errors#1871

Draft
Anas12091101 wants to merge 1 commit intoopenedx:masterfrom
mitodl:anas/display-detailed-error-message
Draft

feat: display detailed error message for 403 catalog visibility errors#1871
Anas12091101 wants to merge 1 commit intoopenedx:masterfrom
mitodl:anas/display-detailed-error-message

Conversation

@Anas12091101
Copy link
Contributor

@Anas12091101 Anas12091101 commented Mar 6, 2026

Description

Previously, when a course had catalog_visibility set to "none", the backend returned a generic HTTP 404 with "Course not found.". I have created openedx/openedx-platform#38121 to return an HTTP 403 with a meaningful error message and an error_code of "not_visible_in_catalog".

The Learning MFE was only handling errors generically, showing "There was an error loading this course." for all failure cases. This PR updates the frontend to detect 403 responses, extract the detail message and error_code from the response body, and display the meaningful error message to the user instead of the generic one.

If the error response does not include a custom message, the existing generic message is shown as a fallback.

Screenshots

Before

Screenshot 2026-03-06 at 5 06 22 PM

After

Screenshot 2026-03-06 at 5 05 46 PM

Testing Instructions

  1. Checkout to this edx-platform branch: https://github.com/mitodl/edx-platform/tree/anas/display-detailed-error-message
  2. Ensure COURSE_ABOUT_VISIBILITY_PERMISSION = 'see_about_page' is set in your LMS settings.
  3. In Studio (Authoring MFE), open a course and go to Settings > Advanced Settings.
  4. Find the Course visibility In catalog field and set it to "none". Save.
  5. Log in as a non-staff user (or use an incognito window with a learner account).
  6. Navigate to the course in the Learning MFE, e.g. http://local.openedx.io:8000/learning/course/course-v1:Org+Course+Run/home.
  7. Alternatively, hit the API directly: GET /api/course_home/course_metadata/course-v1:Org+Course+Run.

Expected (after this change):

  • The API returns HTTP 403 with a JSON body containing:
    • "detail": "This course is not currently accessible. The course team has restricted access to this content. Please contact the course team for further assistance."
    • "error_code": "not_visible_in_catalog"

Expected (before this change):

  • The API returned HTTP 404 with "detail": "Course not found.".
  1. Verify that the error is shown on the learning MFE page correctly.

  2. Log in as a staff/admin user and repeat step 4 or 5.

    • The course should load normally (HTTP 200) — staff access bypasses catalog visibility restrictions.
  3. Set Course Visibility In Catalog back to "both" and verify the course loads normally for all users.

@openedx-webhooks
Copy link

openedx-webhooks commented Mar 6, 2026

Thanks for the pull request, @Anas12091101!

This repository is currently maintained by @openedx/committers-frontend-app-learning.

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.

🔘 Update the status of your PR

Your PR is currently marked as a draft. After completing the steps above, update its status by clicking "Ready for Review", or removing "WIP" from the title, as appropriate.


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 Mar 6, 2026
@github-project-automation github-project-automation bot moved this to Needs Triage in Contributions Mar 6, 2026
@codecov
Copy link

codecov bot commented Mar 6, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 91.16%. Comparing base (4af279e) to head (9c20825).

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #1871      +/-   ##
==========================================
+ Coverage   91.13%   91.16%   +0.03%     
==========================================
  Files         349      349              
  Lines        5807     5830      +23     
  Branches     1376     1386      +10     
==========================================
+ Hits         5292     5315      +23     
  Misses        496      496              
  Partials       19       19              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Copy link
Contributor

@arbrandes arbrandes left a comment

Choose a reason for hiding this comment

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

The code here looks good, thanks!

However, let's put this in Draft until the edx-platform PR lands.

@arbrandes arbrandes marked this pull request as draft March 9, 2026 13:59
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: Ready for Review

Development

Successfully merging this pull request may close these issues.

3 participants