Skip to content

fix: surface tab-data errors instead of silently swallowing them on access denial - #2054

Closed
asadali145 wants to merge 1 commit into
openedx:masterfrom
mitodl:asadali145/embargo-graceful-block
Closed

fix: surface tab-data errors instead of silently swallowing them on access denial#2054
asadali145 wants to merge 1 commit into
openedx:masterfrom
mitodl:asadali145/embargo-graceful-block

Conversation

@asadali145

Copy link
Copy Markdown
Contributor

What are the relevant tickets?

N/A

Description (What does it do?)

Course tab pages (dates, progress, outline) silently swallowed HTTP 403 responses from their tab-data endpoints, returning an empty object instead of surfacing an error. That assumed 403 always meant "course access denied, handled by the metadata request's redirect" — but a 403 can also come from something like an embargo block on the tab-data endpoint itself, unrelated to the metadata call. Learners hit that case saw a blank/broken tab with no explanation.

  • api.js: 403 now re-throws like any other error on getDatesTabData, getProgressTabData, getOutlineTabData.
  • TabPage.tsx: deriveView() now derives isDenied and isError as independent flags instead of mutually-exclusive branches, so:
    • a denied learner with a real redirect target still redirects, even if tab-data also failed
    • a denied learner with no redirect target (the outline tab's "show the page anyway" case) now shows an error instead of silently rendering with no data
Implementation details

getDatesTabData/getProgressTabData still swallow HTTP 401 the same way 403 used to be swallowed - left alone in this PR since removing it changes user-visible behavior beyond this fix's scope. Flagging it here as a known follow-up, not fixed now.

How can this be tested?

npx jest src/tab-page/TabPage.test.jsx src/course-home/data/api.test.js src/course-home/data/apiHooks.test.tsx - 55/55 passing, including new cases covering: 403 re-thrown at the API layer, the hook surfacing isError for dates/progress/outline, and TabPage rendering the right outcome across the redirect-target x tab-data-outcome matrix.

Additional Context

No UI/visual change - same error page, just reachable from a case it previously silently swallowed.

…ccess denial

Previously api.js silently swallowed HTTP 403 on the dates/progress/outline
tab-data endpoints, returning {} on the assumption that course access is
always handled via the metadata request's redirect. That assumption breaks
when the tab-data endpoint itself returns 403 for a different reason (e.g. an
embargo block), leaving learners on a blank tab with no explanation.

403 now re-throws like any other error. TabPage's deriveView() derives
isDenied/isError as independent flags so a denied learner with a real
redirect target still redirects even if tab-data also failed, while a denied
learner with no redirect target (outline) now surfaces an error instead of
silently rendering with no data.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
@openedx-webhooks

Copy link
Copy Markdown

Thanks for the pull request, @asadali145!

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.

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.

@asadali145

Copy link
Copy Markdown
Contributor Author

Closing in favor of #2055, which takes a different approach - scoping the country-embargo check down to the course_metadata endpoint only (see the companion openedx-platform PR) instead of the data-layer 403 handling here.

@asadali145 asadali145 closed this Sep 8, 2026
@github-project-automation github-project-automation Bot moved this from Needs Triage to Done in Contributions Sep 8, 2026
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: Done

Development

Successfully merging this pull request may close these issues.

2 participants