mdn / mdn/dex

PR preview pages don't handle visit to non deployed pages well

Open
#76 6 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
JavaScript
Stars
6
Forks
4
Avg merge
21h 12m
Merged PRs (30d)
32

Description

Summary

Previews generated by the PR review companion include only the modified files. On preview pages, links to other unmodified pages give a 404 error. Also, the error is wrong: Key: pr37670/en-us/_spas/404.html. Following is the content of the 404 response:

404 Not Found
Code: NoSuchKey
Message: The specified key does not exist.
Key: pr37670/en-us/_spas/404.html
RequestId: W9ZG8PFR8V5N0MK5
HostId: EoaAHM8g7wgSv7rGa1dRb6/F9o5Pg93I6h0iZVYuA8A5x1RrlpNKgHZVADEZDyl/ZnC2KuEdIr8=

Reviewers find it annoying to see the 404 page instead of the requested page, even though it's not modified in the PR. It would be better if, on the 404 page, there is a link to the page on the production site.

Steps to reproduce

  1. Open any latest PR in the mdn/content repo.
  2. Open any preview page.
  3. On the page, click on any link to an MDN page that is not modified in the PR.
  4. You'll get pr37670/en-us/_spas/404.html not found error.

Solution

The solution is based on the TamporMonkey script created by Will. The script adds a link to the same doc on the production site. Instead of TamporMonkey, we can do it in the deployer code itself.\

During dev deployments for PRs, populate the /en-us/_spas/404.html file with the following content:

<!DOCTYPE html>
<HTML>
  <head>
      <title>404 Page Not Found</title>
  </head>
  <body>
    <h1>404 Page Not Found</h1>
    <script>
      if (document.location.hostname.endsWith("content.dev.mdn.mozit.cloud")) {
        const link = document.createElement("a");
        link.href = `https://developer.mozilla.org${document.location.pathname}`;
        link.textContent = "View on MDN production server.";
        document.body.appendChild(link);
      }
    </script>
  </body>
</html>

Note: Ignore the fact that PR build doesn't populate the original _spas/404.html. The production style 404 page is not useful in PR previews anyway.

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with .github/workflows/pr-test.yml around line 106 and trace how PR preview files are deployed. Reproduce the missing-page link from a current preview, then verify that /en-us/_spas/404.html provides a link to the matching developer.mozilla.org path. Done means unmodified-page links no longer show the unusable storage 404 response.

Written by the indexing model from the issue text.

Assessment

Tech stack
github-actions, javascript
Domain
devops, infrastructure
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
42/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.