Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Broken link found where it should not on relative (same folder) link #9876

Closed
7 of 8 tasks
axel7083 opened this issue Feb 21, 2024 · 6 comments
Closed
7 of 8 tasks

Broken link found where it should not on relative (same folder) link #9876

axel7083 opened this issue Feb 21, 2024 · 6 comments
Labels
bug An error in the Docusaurus core causing instability or issues with its execution closed: duplicate This issue or pull request already exists in another issue or pull request

Comments

@axel7083
Copy link
Contributor

axel7083 commented Feb 21, 2024

Have you read the Contributing Guidelines on issues?

Prerequisites

  • I'm using the latest version of Docusaurus.
  • I have tried the npm run clear or yarn clear command.
  • I have tried rm -rf node_modules yarn.lock package-lock.json and re-installing packages.
  • I have tried creating a repro with https://new.docusaurus.io.
  • I have read the console error message carefully (if applicable).

Description

Error message got

  Exhaustive list of all broken links found:
  - Broken link on source page path = /api/interfaces/EndpointSettings:
     -> linking to EndpointIPAMConfig.md (resolved as: /api/interfaces/EndpointIPAMConfig.md)

Let's break it down. On page /api/interfaces/EndpointSettings specifically, let's find the link to the EndpointIPAMConfig.md file.

  • Here is the broken link : [EndpointIPAMConfig](EndpointIPAMConfig.md)

It is using relative link, and have the .md suffix. (just like many other links in the same folder)

  • EndpointIPAMConfig.md and EndpointIPAMConfig.md are in the same folders.

Debugging the issue.

Let's run the debugger for the building process. I added some breakpoints in the handleBrokenLinks.

Inside the isPathBrokenLink we got the following, when we reached linkPath === { "pathname": "/api/interfaces/EndpointIPAMConfig.md" }

image

Let's evaluate the validPathnames (used for optimizations)

with .md without
image image

Since the file with the .md suffix is not included in the validPathnames, we result in calling the react-router-config method matchRoutes.

However it has not any chance of success since this are the provided arguments

image

Resulting in the link being added to the brokens list

image

Reproducible demo

No response

Steps to reproduce

(1) git clone https://github.com/axel7083/docusaurus-reproductible-broken-link
(2) npm install
(3) npm run build

Wait and see

Expected behavior

Not detecting a broken links as it is not one

Actual behavior

Broken link detected

Your environment

Self-service

  • I'd be willing to fix this bug myself.
@axel7083 axel7083 added bug An error in the Docusaurus core causing instability or issues with its execution status: needs triage This issue has not been triaged by maintainers labels Feb 21, 2024
@axel7083 axel7083 changed the title Broken link found where it should not Broken link found where it should not on relative (same folder) link Feb 21, 2024
@axel7083
Copy link
Contributor Author

I added a minimal reproductible example here https://github.com/axel7083/docusaurus-reproductible-broken-link

@axel7083
Copy link
Contributor Author

cc @slorber

@slorber
Copy link
Collaborator

slorber commented Feb 22, 2024

The problem is not in the broken link checker. Markdown relative file links should be resolved before reaching the broken link checker, and not end with .md.

The problem is in our legacy replaceMarkdownLinks function and how it handles fenced code blocks with hacky regexes.

A minimal repro:

```something```

[test](test.md)

It's not clear to me why you use "inline triple backticks" instead of regular inline code blocks, but you can probably fix the problem by migrating to regular inline code blocks.

The solution should be #9048, so I'm closing this issue as a duplicate.

@slorber slorber closed this as not planned Won't fix, can't repro, duplicate, stale Feb 22, 2024
@slorber slorber added closed: duplicate This issue or pull request already exists in another issue or pull request and removed status: needs triage This issue has not been triaged by maintainers labels Feb 22, 2024
@axel7083
Copy link
Contributor Author

The problem is not in the broken link checker. Markdown relative file links should be resolved before reaching the broken link checker, and not end with .md.

The problem is in our legacy replaceMarkdownLinks function and how it handles fenced code blocks with hacky regexes.

A minimal repro:

```something```

[test](test.md)

It's not clear to me why you use "inline triple backticks" instead of regular inline code blocks, but you can probably fix the problem by migrating to regular inline code blocks.

The solution should be #9048, so I'm closing this issue as a duplicate.

The markdown is generated by https://github.com/tgreyuk/typedoc-plugin-markdown

@slorber
Copy link
Collaborator

slorber commented Feb 22, 2024

I see thanks, will track the issue to see what the author has to say.

@melroy89
Copy link

This is a very nasty bug and hard to debug! Please support triple backticks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug An error in the Docusaurus core causing instability or issues with its execution closed: duplicate This issue or pull request already exists in another issue or pull request
Projects
None yet
Development

No branches or pull requests

3 participants