Skip to content

The yarn content fix-redirects command doesn't remove a redirect #210

@OnkarRuikar

Description

@OnkarRuikar

What information was incorrect, unhelpful, or incomplete?

Summary

If there exists a redirect from document abc to xyz in the _redirects.txt file, and a contributor creates a brand new document abc, in this case, the yarn content validate-redirects en-US throws an error saying the redirect resolves to an existing folder. To fix this redirect error if the yarn content fix-redirects command is used, it doesn't remove the redirect from the _redirects.txt file.
In such cases, we've been asking the contributors to manually remove the redirects.

Steps to reproduce

  1. In the mdn/content repo create a file files/en-us/ajax/index.md
  2. Add the following content to the file
    ---
    title: ajax
    slug: AJAX
    page-type: landing-page
    ---
    
    {{GamesSidebar}}
    
    Gaming is one of the most popular computer activities. New technologies are constantly arriving to make it possible to develop better and more powerful games that can be run in any standards-compliant web browser.
    
  3. Now run yarn content validate-redirects en-US

    Error: Invalid 'from' URL for redirect: From-URL '/en-us/docs/ajax' resolves to an existing folder at 'en-us/ajax/index.md' for locale 'en-US'.
    error Command failed with exit code 1.

  4. To fix the redirect error, now run the yarn content fix-redirects command.
  5. Notice the command completes without any error. But it doesn't update the _redirects.txt file.
  6. The error remains unfixed.

What did you expect to see?

The fix-redirects command must remove redirects if the from document exists. It shouldn't matter if to document exists or not.

Do you have any supporting links, references, or citations?

Here is a conversation from the Slack channel:

Hamish: If I create a document that is redirected I get a warning. I can fix this by deleting the redirect, but our guidance in contributing.md is never to directly edit the redirects file. Just FMI, is there another way?

Chen: Yes, you need to manually edit

Do you have anything more you want to share?

Should these tool/content commands be documented in the rari repo or in the content repo?

Metadata

Metadata

Assignees

No one assigned

    Labels

    needs triageTriage needed by staff and/or partners. Automatically applied when an issue is opened.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions