Skip to content

contents validator fails if a symlink is present #781

@abid-mujtaba

Description

@abid-mujtaba

If a PR includes a symlink the contents validator fails with:

TypeError [ERR_INVALID_ARG_TYPE]: The first argument must be of type string or an instance of Buffer, ArrayBuffer, or Array or an Array-like Object. Received undefined
    at Function.from (node:buffer:325:9)
    at GithubAPI.getContent (/workspace/lib/github/api.js:113:21)
    at async Contents.validate (/workspace/lib/validators/contents.js:62:23)
    at async Promise.all (index 1)
    at async logicalConnectiveValidatorProcessor (/workspace/lib/validators/lib/logicalConnectiveValidatorProcessor.js:45:18)
    at async Promise.all (index 0)
    at async processWorkflow (/workspace/lib/flex/lib/processWorkflow.js:104:20)
    at async executeMergeable (/workspace/lib/flex/flex.js:40:3)
    at async /workspace/lib/mergeable.js:102:7
    at async Promise.all (index 0)

I believe that when the file it is analyzing is a symlink the res.data.content call on this line returns undefined which causes Buffer.from() to throw an error.

A possible solution would be to inspect res.data.type === 'symlink' first and skip if it is true since technically the symlink itself has no "contents" to speak of.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions