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

Silent failure when config file contains invalid json #201

Open
MichaelSimons opened this issue Aug 22, 2024 · 1 comment
Open

Silent failure when config file contains invalid json #201

MichaelSimons opened this issue Aug 22, 2024 · 1 comment

Comments

@MichaelSimons
Copy link

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
@gaurav-nelson
Copy link
Owner

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.

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

No branches or pull requests

2 participants