@actions/exec: `exec(commandLine)` drops `""` arguments and trims trailing spaces of the last argument

オープン 初心者向け
#2,569 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る

メンテナーはふだん 1 日以内に返信

@bardrop がすでに取り組んでいます。

2026年11月12日 から。

  • #2577 @bardrop による — オープン

評価

難易度
2/5
見積もり時間
1〜3時間
初心者へのやさしさ
83/100
issue の種類
バグ
明瞭さ
明確に書かれている
活発さ
活発
技術スタック
node.js, typescript
領域
cli, devtools

調査の方向性

packages/exec/src/toolrunner.tsから始めてargStringToArrayを調べ、特に空の引用符付き引数と最後の引数の扱いを確認してください。exec.execまたはexec.getExecOutputを使ってissueの例を再現してください。3つすべてのケースで空の引数と末尾のスペースが保持されれば完了です。

索引モデルが issue の本文から書いたものです。

説明

Describe the bug
When exec.exec (or exec.getExecOutput) is called with the command and arguments in a single commandLine string, argStringToArray silently drops any empty double-quoted argument ("") and trims trailing whitespace from the last argument only. A command like ssh-keygen -N "" -f key runs as ssh-keygen -N -f key, causing -f to be consumed as the value of -N.

To Reproduce

// repro.mjs
import * as exec from '@actions/exec'
const show = 'node -e "console.log(JSON.stringify(process.argv.slice(1)))" --'
await exec.exec(`${show} -N "" -f key`)
await exec.exec(`${show} -m "fix typo "`)
await exec.exec(`${show} -m "fix typo " x`)
npm i @actions/exec
node repro.mjs

Actual output:

[command]/usr/bin/node -e console.log(JSON.stringify(process.argv.slice(1))) -- -N -f key
["-N","-f","key"]
[command]/usr/bin/node -e console.log(JSON.stringify(process.argv.slice(1))) -- -m fix typo
["-m","fix typo"]
[command]/usr/bin/node -e console.log(JSON.stringify(process.argv.slice(1))) -- -m fix typo  x
["-m","fix typo ","x"]

Expected behavior

["-N","","-f","key"]
["-m","fix typo "]
["-m","fix typo ","x"]

Screenshots
Not applicable.

Desktop (please complete the following information):

  • OS: Linux x86_64
  • Browser: N/A
  • Version: @actions/exec 3.0.0 (actions/toolkit main 0c3a9c3), Node.js v26.13.0

Smartphone (please complete the following information):

  • Device: N/A
  • OS: N/A
  • Browser: N/A
  • Version: N/A

Additional context
In packages/exec/src/toolrunner.ts, argStringToArray only pushes an argument when arg.length > 0 (so "" is discarded), and the final push after the loop uses arg.trim() while earlier pushes do not.

Credit: https://ucsbplse.github.io/

主要言語
TypeScript
スター
5.9k
フォーク
1.8k
平均マージ
15分
マージ済み PR(30日)
1

環境構築

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

actions/toolkit のほかの issue

actions/toolkit の issue をすべて見る

似ている issue

TypeScript の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。