Skip to content

Google search: Check for metatags before assigning object property

Sarah German requested to merge gps-pagemap-empty into main

What does this MR do and why?

Fixes a bug with search when returning a result without any indexed metatags.

There are rare cases where Google can return a result with an empty pagemap.metatags object. This example search might still show this: https://docs.gitlab.com/search/?q=gitlab%20flow&page=1 ("Error fetching results. Please try again later.")

In this case, the "GitLab Flow" page that causes the error no longer exists on the site, but it's still in Google's index. This is a known possibility; Google's index may sometimes be out of sync with the site temporarily, and the way we do client-side redirects might be a factor as well (#1387).

What's surprising is that it comes back as a result but with empty metatags, but that's not something we can fix on our side. So, for now, we can at least not return an error if this happens. This MR explicitly checks for metatags before trying to use them, preventing the error.

Screenshots, screen recordings, or links to review app

before after
image image

How to validate

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

  1. Search for "flow" on the live site: https://docs.gitlab.com/search/?q=flow&page=1 (this will likely return an error)
  2. Search for "flow" on the review app: https://gps-pagemap-empty.docs.gitlab-review.app/search/?q=flow&page=1 (no error, but the top result goes to a 404; we'll investigate further in a follow-up)

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