actions / actions/toolkit

exec should not fail if provided a command with a missing tool when using {ignoreReturnCode: true, failOnStdErr:false}

Open
#1,625 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

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

Description

Describe the bug
I would expect that exec.exec('someCommandThatDoesNotExists', [], {ignoreReturnCode:true, failOnStdErr:false}) would simply return a Promise that resolves to 127.
Instead it appears that it throws an exception: which ultimately comes from the fact that it is using io.which with a check flag equal to true over at https://github.com/actions/toolkit/blob/main/packages/exec/src/toolrunner.ts#L411

To Reproduce
Steps to reproduce the behavior:
From a custom javascript based github action perform
const exitCode = await exec.exec('someCommandThatDoesNotExists', [], {ignoreReturnCode:true, failOnStdErr:false})
and a execute the action

Expected behavior
You'll find that instead of getting the exitCode to process yourself, an exception is thrown. This is not at all what is expected from users like myself when I explicitly requested to process the return code myself with
ignoreReturnCode:true, failOnStdErr:false

A Promise that resolves to 127 should be returned.

Desktop (please complete the following information):
all platforms

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 at packages/exec/src/toolrunner.ts around line 411, where io.which is called with check enabled, and reproduce the issue from a custom JavaScript GitHub Action using exec.exec with both options. Done means a missing command resolves with exit code 127 instead of throwing when ignoreReturnCode is true and failOnStdErr is false.

Written by the indexing model from the issue text.

Assessment

Tech stack
github-actions, node.js, typescript
Domain
cli, devtools
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
38/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.