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

404 on links to section headers that exist in the same file #250

Closed
philrz opened this issue Mar 27, 2023 · 3 comments · Fixed by #312
Closed

404 on links to section headers that exist in the same file #250

philrz opened this issue Mar 27, 2023 · 3 comments · Fixed by #312

Comments

@philrz
Copy link

philrz commented Mar 27, 2023

I've found some strange 404 errors when running markdown-link-check on the attached file zng.md.

Testing that file locally with v3.11.0, the two 404 errors are unexpected. The headers for all three of these sections look much the same in the markdown.

$ npm install -g markdown-link-check

$ markdown-link-check --version
3.11.0

$ markdown-link-check zng.md

FILE: zng.md
  [✓] #21-types-frame
  [✖] #22-values-frame
  [✖] #23-control-frame

  3 links checked.

  ERROR: 2 dead links found!
  [✖] #22-values-frame → Status: 404
  [✖] #23-control-frame → Status: 404

Then if I remove a particular line from the file, the 404 errors go away.

$ sed 's/A named type is encoded as follows://' zng.md > zng-edited.md

$ markdown-link-check zng-edited.md 

FILE: zng-edited.md
  [✓] #21-types-frame
  [✓] #22-values-frame
  [✓] #23-control-frame

  3 links checked.

I went to clone the repo so I could try debugging the problem myself, but oddly once I did that, I found my version installed from source didn't trigger the problem, even though the version is the same, which also struck me as odd.

$ npm uninstall -g markdown-link-check

$ git clone /~https://github.com/tcort/markdown-link-check.git

$ cd markdown-link-check/

$ git checkout v3.11.0

$ npm install

$ npm install -g

$ markdown-link-check --version
3.11.0

$ markdown-link-check zng.md 

FILE: zng.md
  [✓] #21-types-frame
  [✓] #22-values-frame
  [✓] #23-control-frame

  3 links checked.
@mg-alanjones
Copy link

I noticed the same thing, via MegaLinter.

✅ Linted [MARKDOWN] files with [markdown-link-check]: Found 6 non blocking error(s) - (3.51s) (expand for details)
- Using [markdown-link-check v3.11.2] https://megalinter.io/7.10.0/descriptors/markdown_markdown_link_check
- MegaLinter key: [MARKDOWN_MARKDOWN_LINK_CHECK]
- Rules config: [.markdown-link-check.json]
- Number of files analyzed: [2]
--Error detail:
(node:24) [DEP0040] DeprecationWarning: The `punycode` module is deprecated. Please use a userland alternative instead.
(Use `node --trace-deprecation ...` to show where the warning was created)
  ERROR: 6 dead links found in README.md !
  [✖] #requirements → Status: 404
  [✖] #providers → Status: 404
  [✖] #modules → Status: 404
  [✖] #resources → Status: 404
  [✖] #inputs → Status: 404
  [✖] #outputs → Status: 404

and my code looks like:

- [Table of Contents](#table-of-contents)
- [Usage](#usage)
  - [Examples](#examples)
- [Requirements](#requirements)
- [Providers](#providers)
- [Modules](#modules)
- [Resources](#resources)
- [Inputs](#inputs)
- [Outputs](#outputs)
- [GitLab Groups and Projects (Repositories)](#gitlab-groups-and-projects-repositories)
- [Maintainers](#maintainers)
- [Contributing](#contributing)

To resolve this, I put <!-- markdown-link-check-disable --> before the code and <!-- markdown-link-check-enable --> after the code. Then I received this:

✅ Linted [MARKDOWN] files with [markdown-link-check] successfully - (3.47s) (expand for details)
- Using [markdown-link-check v3.11.2] https://megalinter.io/7.10.0/descriptors/markdown_markdown_link_check
- MegaLinter key: [MARKDOWN_MARKDOWN_LINK_CHECK]
- Rules config: [.markdown-link-check.json]
- Number of files analyzed: [2]

rkitover added a commit to rkitover/markdown-link-check that referenced this issue Apr 5, 2024
Extract markdown heading lines and convert to section link names, check
all section links against this list and return a 404 for any that do not
have a heading.

Filter out code blocks because comments can be false positives for
markdown headers.

Make some minor adjustments for the tests to pass on Windows.

Fix tcort#250

Signed-off-by: Rafael Kitover <rkitover@gmail.com>
rkitover added a commit to rkitover/markdown-link-check that referenced this issue Apr 6, 2024
Extract markdown heading lines and convert to section link names, check
all section links against this list, first removing any code blocks, and
return a 404 for any that do not have a heading.

Check for `baseUrl` option prepended section links as well.

Make some minor adjustments for the tests to pass on Windows.

Fix tcort#250

Signed-off-by: Rafael Kitover <rkitover@gmail.com>
@PeterDaveHello
Copy link
Contributor

PeterDaveHello commented Apr 11, 2024

Same here. I've encountered the exact same issue. After conducting some tests, I believe something broke starting with version 3.12.1.(v3.12.0 is broken for me to verify the issue) Testing with version 3.11.2 yields no such problems.

PeterDaveHello added a commit to nodejs/docker-node that referenced this issue Apr 11, 2024
Pin to v3.11.0 in GitHub Actions workflow to avoid false positive 404 
errors in CI.

Refs:
- tcort/markdown-link-check#250
@PeterDaveHello
Copy link
Contributor

I'm currently encountering an issue that seems to be similar across different software versions, though there appears to be some variation in the specific versions impacted.

Initially, I experienced this problem with version 3.11.0. However, after some troubleshooting, version 3.11.0 is now functioning correctly for me, but I don't know why. And, the issue persists with the latest release, version 3.12.1. The problem may be consistent across these versions, albeit manifesting under slightly different conditions or configurations.

rkitover added a commit to rkitover/markdown-link-check that referenced this issue Apr 12, 2024
Extract markdown heading lines and convert to section link names, check
all section links against this list, first removing any code blocks, and
return a 404 for any that do not have a heading.

Check for `baseUrl` option prepended section links as well.

Add tests for this functionality.

Make some minor adjustments for the tests to pass on Windows.

Fix tcort#250

Signed-off-by: Rafael Kitover <rkitover@gmail.com>
rkitover added a commit to rkitover/markdown-link-check that referenced this issue Apr 12, 2024
Extract markdown heading lines and convert to section link names, check
all section links against this list, first removing any code blocks, and
return a 404 for any that do not have a heading.

Check for `baseUrl` option prepended section links as well.

Add tests for this functionality.

Make some minor adjustments for the tests to pass on Windows.

Fix tcort#250

Signed-off-by: Rafael Kitover <rkitover@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants