github-action-markdown-link-check icon indicating copy to clipboard operation
github-action-markdown-link-check copied to clipboard

Silent failure when config file contains invalid json

Open MichaelSimons opened this issue 1 year ago • 1 comments
trafficstars

Create a malformed json config file and run the GH action when there are invalid links. When this happens the action will pass with no errors.

I discovered this while trying to add a comment (not strictly supported by the json protocol) in my config file. Testing further I discovered any type of syntax error did not result in a failure.

Some config files tried

{
    "ignorePatterns": [
        // This folder is not always defined
        {
            "pattern": "^https://github.com/dotnet/sdk/tree/main/src/SourceBuild/patches"
        },
     ],
    "aliveStatusCodes": [200, 203]
}
/ {
    "ignorePatterns": [
 /   ],
    "aliveStatusCodes": [200, 203]
}

I tested directly on the tcort/markdown-link-check tool and it will fail as I expected:

(node:1) [DEP0040] DeprecationWarning: The `punycode` module is deprecated. Please use a userland alternative instead.
(Use `node --trace-deprecation ...` to show where the warning was created)

FILE: /tmp/README.md
undefined:1
/{
^

SyntaxError: Unexpected token '/', "/{
    "i"... is not valid JSON
    at JSON.parse (<anonymous>)
    at ReadStream.<anonymous> (/src/markdown-link-check:156:34)
    at ReadStream.emit (node:events:520:28)
    at endReadableNT (node:internal/streams/readable:1696:12)
    at process.processTicksAndRejections (node:internal/process/task_queues:82:21)

Node.js v22.2.0

MichaelSimons avatar Aug 22 '24 16:08 MichaelSimons

Thank you @MichaelSimons for creating this issue. I have developed a new tool called Linkspector, which offers improved functionality and reduced false positives. I recommend using Linkspector action for your needs, which is now the preferred and supported option.

gaurav-nelson avatar Aug 26 '24 06:08 gaurav-nelson