actions / actions/toolkit

[glob] readdir causes EACCES: permission denied, scandir

Open
#775 4 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug glob
Dominant language
TypeScript
Stars
5.9k
Forks
1.8k
PR merge metrics
No merged PRs in 30d

Description

https://github.com/actions/toolkit/blob/fc005283374f1cea5e03ea1caf959cd9ff12fdc2/packages/glob/src/internal-globber.ts#L142-L145

As you can see from the above snippet, internal-globber.ts doesn't check if the directory is readable before attempting to read it.

There should be a try catch block around that code:

try {
  const childLevel = item.level + 1;
  const childItems = (await fs.promises.readdir(item.path)).map(
    x =>  new SearchState(path.join(item.path, x), childLevel)
  );
  stack.push(...childItems.reverse());
catch (err) {
  if (err.code === 'EACCES') {
    continue;
  }
  throw err;
}

This issue affects the upload-artifacts action, plus I'm sure other actions that depend on this package.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start in packages/glob/src/internal-globber.ts at lines 142-145, where readdir is called while traversing directories. Verify how permission-denied errors are currently handled, then confirm that EACCES directories are skipped while other errors still propagate; the change should prevent upload-artifacts and other glob users from failing on unreadable directories.

Written by the indexing model from the issue text.

Assessment

Tech stack
typescript
Domain
tooling
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
38/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.