mergeable icon indicating copy to clipboard operation
mergeable copied to clipboard

contents validator fails if a symlink is present

Open abid-mujtaba opened this issue 7 months ago • 0 comments

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.

abid-mujtaba avatar May 06 '25 00:05 abid-mujtaba