runner icon indicating copy to clipboard operation
runner copied to clipboard

Diagnostics for `hashFiles` failing on a broken symlink don't describe the problem

Open huonw opened this issue 2 years ago • 2 comments

Describe the bug

Currently if hashFiles hits a broken symlink it fails the step hard with an opaque error: it says that there is a problem, but no guidance about what it was. For instance:

Error: The template is not valid. .github/workflows/test.yml (Line: 14, Col: 14): hashFiles('*') failed. Fail to hash files under directory '/home/runner/work/GitHub-runner-broken-symlink-diagnostics/GitHub-runner-broken-symlink-diagnostics'

That is all it says, without debug logging. This is confusing and frustrating, and is even worse with a glob like some-directory/**/*: who knows which file somewhere under that directory is the problem.

Given the job is failing, preferably this would do at least one of:

  1. include which file(s) is causing the problem
  2. suggest how to find more information, e.g. "turn on debug logging".

Debug logging helps with this, somewhat, if one knows what to look for (I had to find https://github.com/actions/runner/issues/1666 to realise I could search for ENOENT in the logs, since there was too much output to look at manually):

##[debug]Error: ENOENT: no such file or directory, stat '/home/runner/work/GitHub-runner-broken-symlink-diagnostics/GitHub-runner-broken-symlink-diagnostics/broken'
##[debug]    at Object.statSync (node:fs:1583:3)
##[debug]    at /home/runner/runners/2.311.0/bin/hashFiles/index.js:84:24
##[debug]    at Generator.next (<anonymous>)
##[debug]    at fulfilled (/home/runner/runners/2.311.0/bin/hashFiles/index.js:35:58) {
##[debug]  errno: -2,
##[debug]  syscall: 'stat',
##[debug]  code: 'ENOENT',
##[debug]  path: '/home/runner/work/GitHub-runner-broken-symlink-diagnostics/GitHub-runner-broken-symlink-diagnostics/broken'
##[debug]}

To Reproduce

  1. Have a broken symlink somehow
  2. Have a hashFiles call in the workflow that includes that symlink
  3. See error and then struggle to understand what needs to be changed to fix the problem

Example: https://github.com/huonw/GitHub-runner-broken-symlink-diagnostics

  • run without debug logging: https://github.com/huonw/GitHub-runner-broken-symlink-diagnostics/actions/runs/7028745161/job/19125215085
  • run with debug logging: https://github.com/huonw/GitHub-runner-broken-symlink-diagnostics/actions/runs/7028745161/job/19125266914

Expected behavior

It would be better if the error message said:

  1. which files are a problem (preferably if there's multiple files that are a problem, highlight them all)
  2. why they're a problem (e.g. "symlink to file that doesn't exist")

1 is most critical, but 2 would be great.

Runner Version and Platform

Current runner version: '2.311.0'
Operating System
  Ubuntu
  22.04.3
  LTS

What's not working?

The error is opaque, currently:

Error: The template is not valid. .github/workflows/test.yml (Line: 14, Col: 14): hashFiles('*') failed. Fail to hash files under directory '/home/runner/work/GitHub-runner-broken-symlink-diagnostics/GitHub-runner-broken-symlink-diagnostics'

Job Log Output

  • run without debug logging: https://github.com/huonw/GitHub-runner-broken-symlink-diagnostics/actions/runs/7028745161/job/19125215085
  • run with debug logging: https://github.com/huonw/GitHub-runner-broken-symlink-diagnostics/actions/runs/7028745161/job/19125266914

Runner and Worker's Diagnostic Logs

N/A

huonw avatar Nov 29 '23 06:11 huonw

This is still an issue. Any advice on workarounds or resolutions would be much appreciated!

oldgalileo avatar Mar 28 '24 04:03 oldgalileo

You can currently debug this by turning on debug logs and searching for ENOENT. If there's no results, you may be affected by a different problem, or be running on a different system.

huonw avatar Apr 01 '24 23:04 huonw