nil pointer dereference panic
$ htmltest -l0 -c .htmltest.yml -s public/
results in
[many lines of output ]
skipping external check --- [path]/index.html --> [url]
testDocument on [path]/index.html
panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x30 pc=0x110fbc6]
goroutine 1 [running]:
github.com/wjdp/htmltest/htmldoc.(*Document).Parse(0x0)
/home/travis/gopath/src/github.com/wjdp/htmltest/htmldoc/document.go:47 +0x26
github.com/wjdp/htmltest/htmldoc.(*Document).IsHashValid(0x0, 0xc024516666, 0xc, 0x1278600)
/home/travis/gopath/src/github.com/wjdp/htmltest/htmldoc/document.go:112 +0x2b
github.com/wjdp/htmltest/htmltest.(*HTMLTest).checkInternalHash(0xc0000b4fc0, 0xc02457bfb0)
/home/travis/gopath/src/github.com/wjdp/htmltest/htmltest/check-link.go:297 +0xad
github.com/wjdp/htmltest/htmltest.(*HTMLTest).checkInternal(0xc0000b4fc0, 0xc02457bfb0)
/home/travis/gopath/src/github.com/wjdp/htmltest/htmltest/check-link.go:271 +0xcb
github.com/wjdp/htmltest/htmltest.(*HTMLTest).checkLink(0xc0000b4fc0, 0xc00032b380, 0xc024532e00)
/home/travis/gopath/src/github.com/wjdp/htmltest/htmltest/check-link.go:85 +0x3f9
github.com/wjdp/htmltest/htmltest.(*HTMLTest).testDocument(0xc0000b4fc0, 0xc00032b380)
/home/travis/gopath/src/github.com/wjdp/htmltest/htmltest/htmltest.go:203 +0x193
github.com/wjdp/htmltest/htmltest.(*HTMLTest).testDocuments(0xc0000b4fc0)
/home/travis/gopath/src/github.com/wjdp/htmltest/htmltest/htmltest.go:182 +0x6a
github.com/wjdp/htmltest/htmltest.Test(0xc000063aa0, 0x1, 0x1, 0x49)
/home/travis/gopath/src/github.com/wjdp/htmltest/htmltest/htmltest.go:142 +0x8fb
main.run(0xc000063aa0, 0xc000063aa0)
/home/travis/gopath/src/github.com/wjdp/htmltest/main.go:159 +0x1e8
main.main()
/home/travis/gopath/src/github.com/wjdp/htmltest/main.go:66 +0x298
Not sure what is leading to the fault, or what I can do to fix it. Let me know if there is other debug info that might be useful!
$ htmltest --version
htmltest 0.10.1
2018-10-02T21:20:31Z
$ cat .htmltest.yml
DirectoryPath: "public"
IgnoreAltMissing: true
IgnoreDirectoryMissingTrailingSlash: true
CheckImages: false
It looks like the issue happens when the html being tested attempts to link to a hash in a file that does not exist:
<a href="/file/that/does/not/exist.md#hash-link">
gets the panic
while
<a href="/file/that/does/not/exist.md">
finds and warns correctly on the missing file.
Took a bit of work to find the issue, but I think that's the problem
Thanks for the report and investigation!
Does this happen if the linked file is an HTML file rather than markdown?
Ah, we have a (slightly crazy) naming hack in a Hugo app. It's serving html, though the url suggests otherwise.
Context: the hack is in place so that we can build a version of a site that maps 1:1 between a github repo and the site that is built from that content, with the links still working. It's not a pretty answer, but it is sort of working.
The page served at /file/that/does/exist.md is an html page.