Skip to content

Adds support for strings or maps as input to health-reasons partial

Darby Frey requested to merge string-or-maps-health-reasons into main

Why is this change being made?

This MR introduces a fix for the issue described here, which is a specific case that causes the site to fail to build.

The : in this string causes Hugo to convert it to a hash (or a map) which causes the call to the plainify transform to fail, which fails the build. This string is considered valid YAML, so it's not possible for linting to catch this issue.

The change made in this MR changes the health-reasons.html partial detect if the input is a string or a map and renders the contents accordingly.

Screenshot

Screenshot_2024-05-07_at_4.21.21_PM

Steps to test locally

  1. Get the Handbook running locally and ensure that http://localhost:1313/handbook/engineering/infrastructure/performance-indicators/ loads correctly.

  2. Update layouts/shortcodes/performance-indicators.md line 4 to pull content from 0960b7c95f867a89a22773cf17fd5ac5444e2652 instead of master. So:

    {{- $dataURL := printf "https://gitlab.com/gitlab-com/www-gitlab-com/-/raw/0960b7c95f867a89a22773cf17fd5ac5444e2652/data/performance_indicators/%s.yml" (.Get 0) }}
  3. Delete the cache and rerun the build (for example: rm -rf public/ && hugo server). This should produce the error Error: error building site: render: failed to render pages: render of "section" failed

  4. Checkout this branch string-or-maps-health-reasons and rerun the build (rm -rf public/ && hugo server). It should complete without errors and the http://localhost:1313/handbook/engineering/infrastructure/performance-indicators/ page should load as expected.

Author and Reviewer Checklist

Please verify the check list and ensure to tick them off before the MR is merged.

  • Provided a concise title for this Merge Request (MR)
  • Added a description to this MR explaining the reasons for the proposed change, per say why, not just what
    • Copy/paste the Slack conversation to document it for later, or upload screenshots. Verify that no confidential data is added, and the content is SAFE
  • Assign reviewers for this MR to the correct Directly Responsible Individual/s (DRI)
    • If the DRI for the page/s being updated isn’t immediately clear, then assign it to one of the people listed in the Maintained by section on the page being edited
    • If your manager does not have merge rights, please ask someone to merge it AFTER it has been approved by your manager in #mr-buddies
    • The when to get approval handbook section explains the workflow in more detail
  • For transparency, share this MR with the audience that will be impacted.
    • Team: For changes that affect your direct team, share in your group Slack channel
    • Department: If the update affects your department, share the MR in your department Slack channel
    • Division: If the update affects your division, share the MR in your division Slack channel
    • Company: If the update affects all (or the majority of) GitLab team members, post an update in #whats-happening-at-gitlab linking to this MR

Commits

  • Adds support for strings or maps as input to health-reasons partial

Edited by Darby Frey

Merge request reports