8000 Silent failure when config file contains invalid json · Issue #201 · gaurav-nelson/github-action-markdown-link-check · GitHub
[go: up one dir, main page]

Skip to content

Silent failure when config file contains invalid json #201

@MichaelSimons

Description

@MichaelSimons

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      0