Skip to content

Avoid fatal errors if unable to retrieve versions.json

Sarah German requested to merge sarahg/http-fallback into main

What does this MR do and why?

We fetch the versions.json file from the web when compiling the site. This file is provides logic for the visibility and contents of version-related components (archives banner, versions dropdown menu items). Fetching the same json file for all our different versions allows them to show the same up-to-date version info.

This file could be unavailable during a build for a few reasons:

  • the host is down (like this morning's incident when docs.gitlab.com was down)
  • you don't have internet access

In these cases, we can still proceed to build the site and just provide an empty fallback for the versions file. The experience is degraded (e.g, no versions menu shown), but we can still proceed with the build and not crash.

Screenshots, screen recordings, or links to review app

Before (crash) After (finished compile)
image image

How to set up and validate locally

Numbered steps to set up and validate the change are strongly suggested.

  1. Configure a local GitLab Docs environment: https://gitlab.com/gitlab-org/gitlab-docs/-/blob/main/doc/setup.md.
  2. This is scary, but disconnect your computer from the internet.
  3. Compile the site: make clean && bundle exec nanoc compile

The site should build without crashing, and the versions dropdown will not appear.

Merge request acceptance checklist

This checklist encourages us to confirm any changes have been analyzed to reduce risks in quality, performance, reliability, security, and maintainability.

Edited by Sarah German

Merge request reports