Add script to check invalid redirect URLs in redirects.yaml
What does this MR do and why?
WHAT
- This MR adds a script to check invalid redirect
tolinks. - It tests each link against the links in
public/en-us/sitemap.xmland flag any that aren't valid. - Use case - when doing monthly clean up task, Tech Writers can run this script to make sure that we only have valid redirects going forward.
WHY
- This will help us check for invalid redirects that could potentially cause 404s.
Screenshots, screen recordings, or links to review app
NONE EXPECTED
How to set up and validate locally
Numbered steps to set up and validate the change are strongly suggested.
- Configure a local GitLab Docs environment.
- Check out this branch.
- Run script
node __tests__/navigation/check_redirect_links.cjs. It should flag a few URLs.
Note: there are some links that are getting flagged now. They are actually valid but in redirects.yaml those links don't have the product name as prefix.
INFO: Using sitemap: public/en-us/sitemap.xml
ERROR: No sitemap entry found for redirect 'to' URL: /user/duo_agent_platform/software_development_flow/.
Is the redirect entry valid and has the page been merged yet?
ERROR: No sitemap entry found for redirect 'to' URL: /user/gitlab_duo_chat/turn_on_off/.
Is the redirect entry valid and has the page been merged yet?
ERROR: No sitemap entry found for redirect 'to' URL: /advanced/. <--------- this should have product name "charts" like "/charts/advanced/"
Is the redirect entry valid and has the page been merged yet?
ERROR: No sitemap entry found for redirect 'to' URL: /charts/nginx/. <--------- this should have product name "charts" like "/charts/charts/nginx"
Is the redirect entry valid and has the page been merged yet?
ERROR: No sitemap entry found for redirect 'to' URL: /development/architecture/multiple_database_support/. <--------- this should have product name "omnibus" like "/omnibus/development/architecture/multiple_database_support/"
Is the redirect entry valid and has the page been merged yet?
ERROR: No sitemap entry found for redirect 'to' URL: /development/internal/ci/packages_iteration/. <--------- this should have product name "runner" like "/runner/development/internal/ci/packages_iteration/"
Is the redirect entry valid and has the page been merged yet?
ERROR: No sitemap entry found for redirect 'to' URL: /development/team_members/. <--------- this should have product name "omnibus" like "/omnibus/development/team_members/"
Is the redirect entry valid and has the page been merged yet?
ERROR: No sitemap entry found for redirect 'to' URL: /gitlab_upgrades/. <--------- this should have product name "operator" like "/operator/gitlab_upgrades/"
Is the redirect entry valid and has the page been merged yet?
Out of this list the following are URLs that are actually invalid (not in sitemap.xml).
/user/duo_agent_platform/software_development_flow//user/gitlab_duo_chat/turn_on_off/
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.
- I have evaluated the MR acceptance checklist for this merge request.
Closes #546 (closed)
Edited by Hiru Fernando