UmbrellaDocs/linkspector

Error: Cannot read properties of undefined [BUG]

Closed this issue · 5 comments

Describe the bug
A clear and concise description of what the bug is.

To Reproduce
Steps to reproduce the behavior:

  1. Check out https://github.com/CivicActions/guidebook/
  2. Install and run linkspector with default config
  3. Get a couple of errors, then the following error message:
💥 Error: Cannot read properties of undefined (reading 'start')

Expected behavior
Get a list of any broken links in the repo

Additional context

$ node -v
v22.2.0
$ yarn -v # used to install
1.22.22

I moved all the markdown containing files/directories to a standalone directory to avoid any interactions with other files resulting in this many files:

$ ls
LICENSE.md  README.md  about-civicactions  about-this-guidebook  common-practices-tools  company-policies  employee-benefits  practice-areas
$ find . -name '*.md' | wc -l
139

That resulted in the error above:

../node_modules/.bin/linkspector check
⠋ Configuration file not found. Using default configuration.
# Snip broken links
💥 Error: Cannot read properties of undefined (reading 'start')

I deleted most of the files and it started running fine. I then added them back and removed some directories until it started running:

rm -rf practice-areas/project-management/
rm -rf practice-areas/help-desk/
find . -name '*.md' | wc -l
112

After that the test completed successfully.

../node_modules/.bin/linkspector check
⠋ Configuration file not found. Using default configuration.
# Snip broken links
💥 Error: Some hyperlinks in the specified files are invalid.

Given this, my hypothesis is that it is probably something to do with the number of files. I couldn't identify a specific file that caused it to fail repeatedly, although it's possible that is a cause also. Let me know if I can help test anything or if you need more info :)

Finally - thanks for working on this project! We have been using markdown-link-check for a long time, but have had to keep increasing the number of exceptions due to site adding CDNs. This looks like it should help a lot with this approach (as well as filtering and reporting checks!).

Thank you @grugnog for trying this out.

I identified the issue in your Markdown file at https://github.com/CivicActions/guidebook/blob/master/practice-areas/help-desk/project-support-accessibility-guidelines.md?plain=1#L34 There is an incorrect [ instead of ].

content included in [Section 508 of the Rehabilitation Act[(https://www.access-board.gov/ict).

However, Linkspector should handle such cases better. Keep this issue open and I'll try to fix it.

@gaurav-nelson Ahh, thank you! I guess I needed to be a bit more methodical with my testing!

I think error'ing out with a more helpful message would be a fine improvement here :)

I have the same error still on Linkspector v0.3.9.

https://github.com/kaktusztea/km100/actions/runs/9594211671/job/26456291694

 Running linkspector with reviewdog 🐶 ...
  Error in checking if file #0-bevezet%C5%91-jelz%C5%91k exist! TypeError: Cannot read properties of undefined (reading 'includes')
  Error in checking if file #1-karakteralkot%C3%A1s exist! TypeError: Cannot read properties of undefined (reading 'includes')
  Error in checking if file #2-h%C3%A1tterek exist! TypeError: Cannot read properties of undefined (reading 'includes')
  Error in checking if file #3-k%C3%A9pzetts%C3%A9grendszer exist! TypeError: Cannot read properties of undefined (reading 'includes')
  Error in checking if file #4-fort%C3%A9lyok exist! TypeError: Cannot read properties of undefined (reading 'includes')
  Error in checking if file #5-trad%C3%ADci%C3%B3k exist! TypeError: Cannot read properties of undefined (reading 'includes')
  Error in checking if file #6-harcrendszer-%EF%B8%8F exist! TypeError: Cannot read properties of undefined (reading 'includes')
  Error in checking if file #7-t%C3%A1vols%C3%A1gi-harcrendszer- exist! TypeError: Cannot read properties of undefined (reading 'includes')
  Error in checking if file #8-psz%C3%AD exist! TypeError: Cannot read properties of undefined (reading 'includes')
  Error in checking if file #9-m%C3%A1giarendszer exist! TypeError: Cannot read properties of undefined (reading 'includes')
  Error in checking if file #10-papi-m%C3%A1gia-10- exist! TypeError: Cannot read properties of undefined (reading 'includes')
  Error in checking if file #11-var%C3%A1zst%C3%A1rgyak--10- exist! TypeError: Cannot read properties of undefined (reading 'includes')
  Error in checking if file #12-gy%C3%B3gy%C3%ADt%C3%A1s-gy%C3%B3gyul%C3%A1s exist! TypeError: Cannot read properties of undefined (reading 'includes')
  Error in checking if file #13-m%C3%A9regrendszer-m%C3%A9rgek exist! TypeError: Cannot read properties of undefined (reading 'includes')
  Error in checking if file #14-%C3%A9rz%C3%A9kel%C3%A9s-%C3%A9szlel%C3%A9s-90 exist! TypeError: Cannot read properties of undefined (reading 'includes')
  Error in checking if file #15-szitu%C3%A1ci%C3%B3k-20 exist! TypeError: Cannot read properties of undefined (reading 'includes')
  Error in checking if file start.md#karakteralkot%C3%B3k exist! TypeError: Cannot read properties of undefined (reading 'includes')
  reviewdog: failed to unmarshal rdjson (DiagnosticResult): proto: unexpected EOF
  Error: Process completed with exit code 1.

The problematic page:
https://github.com/kaktusztea/km100/blob/master/md/start.md

The problematic part is a bunch of in-page anchor links which work well (all of them).

[Bevezető](#0-bevezet%C5%91-jelz%C5%91k)  -  [Karakteralkotás](#1-karakteralkot%C3%A1s)\
[Hátterek](#2-h%C3%A1tterek)   -  [Képzettségrendszer](#3-k%C3%A9pzetts%C3%A9grendszer)  -  [Fortélyok](#4-fort%C3%A9lyok)  -  [Tradíciók](#5-trad%C3%ADci%C3%B3k)\
[Harcrendszer](#6-harcrendszer-%EF%B8%8F)  -  [Távolsági Harcrendszer](#7-t%C3%A1vols%C3%A1gi-harcrendszer-)\
[Pszí](#8-psz%C3%AD)  -  [Mágiarendszer](#9-m%C3%A1giarendszer)  -  [Papi mágia](#10-papi-m%C3%A1gia-10-)  -  [Varázstárgyak](#11-var%C3%A1zst%C3%A1rgyak--10-)\
[Gyógyítás, gyógyulás](#12-gy%C3%B3gy%C3%ADt%C3%A1s-gy%C3%B3gyul%C3%A1s)  -  [Méregrendszer, Mérgek](#13-m%C3%A9regrendszer-m%C3%A9rgek)  -  [Érzékelés, Észlelés](#14-%C3%A9rz%C3%A9kel%C3%A9s-%C3%A9szlel%C3%A9s-90)  -  [Szituációk](#15-szitu%C3%A1ci%C3%B3k-20)

Thank you @kaktusztea I tested that repo locally to confirm that this issue was resolved. However, I see that the GitHub action is still using Linkspector 0.3.7. I've updated the action to use the latest version. If you re-run the workflow it should now only report broken links.

Thanks Gaurav,

it works now very well! It has found many broken anchor links (true positives) and I could fix all of them.
Now everything is green 🙂
https://github.com/kaktusztea/km100/actions/runs/9642938190/job/26591839358