Unquoted commit message is causing `npx all-contributors add` to fail on v7.0.0
Maintainers usually reply within 1 day
Nobody has claimed this yet.
Assessment
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Newbie friendliness
- 78/100
- Issue type
- Bug
- Clarity
- Clearly specified
- Activity status
- Active
- Tech stack
- git, javascript, node.js
Research direction
Start in dist/util/git.js at spawnGitCommand, where the issue identifies the shell command construction, and check the Git command call sites for commit and add. Replace shell-string execution with argument-based execution, as described in the issue. Reproduce with commit enabled and run npx all-contributors add octocat code; done means the commit succeeds with the full message and paths containing spaces are handled as arguments.
Written by the indexing model from the issue text.
Description
[!NOTE]
I have ran into this issue after upgrading from[email protected]to the latest v7 release.I have asked LLM to perform an initial debug and generate the following report, which I have manually checked and modified for clarity.
Describe the bug
In v7.0.0, all-contributors add fails at the commit step when "commit": true is set in .all-contributorsrc. The files are updated and staged, then the commit fails with:
Error: error: pathspec 'add' did not match any file(s) known to git
error: pathspec '@octocat' did not match any file(s) known to git
error: pathspec 'as' did not match any file(s) known to git
error: pathspec 'a' did not match any file(s) known to git
error: pathspec 'contributor' did not match any file(s) known to git
The cause is in dist/util/git.js. spawnGitCommand builds one shell string and runs it through exec:
await promisify(exec)(`git ${args.join(' ')}`)
The commit message is passed in args (['commit', '-m', commitMessage]) but is never quoted. The shell splits it on spaces, so git receives commit -m feat: Add @octocat as a contributor. Only feat: is treated as the message, and the remaining words are treated as pathspecs.
This is a regression. 6.26.1 calls spawn('git', args) with an argument array, so no shell is involved and the message arrives intact.
To Reproduce
Steps to reproduce the behavior:
- Create a new directory with a git repository and a README that has the contributors markers:
mkdir ac-repro && cd ac-repro git init && git remote add origin https://github.com/example/repo.git npm init -y npm i [email protected] printf '# t\n\n## Contributors\n\n<!-- ALL-CONTRIBUTORS-LIST:START -->\n<!-- ALL-CONTRIBUTORS-LIST:END -->\n' > README.md - Create
.all-contributorsrcwithcommitenabled:{ "projectName": "repo", "projectOwner": "example", "repoType": "github", "repoHost": "https://github.com", "files": ["README.md"], "imageSize": 100, "commit": true, "commitConvention": "angular", "contributors": [], "contributorsPerLine": 7 } - Commit the initial state:
git add -A && git commit -m init - Run
npx all-contributors add octocat code - See the error:
file:///.../node_modules/all-contributors-cli/dist/util/git.js:43 throw new Error(msg) ^ Error: error: pathspec 'add' did not match any file(s) known to git error: pathspec '@octocat' did not match any file(s) known to git error: pathspec 'as' did not match any file(s) known to git error: pathspec 'a' did not match any file(s) known to git error: pathspec 'contributor' did not match any file(s) known to git at spawnGitCommand (.../dist/util/git.js:43:11) - Run
git status --short. Both files are staged but nothing was committed:M .all-contributorsrc M README.md
Expected behavior
git commit receives the whole message as a single argument and the commit is created, as it was in 6.x (for example docs: add @octocat as a contributor).
A fix is to pass the arguments to execFile or spawn instead of building a shell string, as 6.26.1 did.
Screenshots
Not applicable, the full error output is above.
Additional context
- Node.js: v24.22.1
- Workarounds for 7.0.0: pass
--no-commit(or set"commit": false) and commit manually. - The same string-joining happens for
git add, which receivesabsolutePathFilesfromoptions.filesandoptions.config. From reading the code (I did not test it), a project path containing a space would breakgit addthe same way, and a path with shell metacharacters would be interpreted by the shell. Moving toexecFileorspawnwith an argument array fixes both.
- Dominant language
- JavaScript
- Stars
- 424
- Forks
- 151
- Avg merge
- 2d 1h
- Merged PRs (30d)
- 15
Getting set up
- No Dockerfile or Docker Compose file
- Has a pull request template
- Read the contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from all-contributors/cli
-
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
all-contributors/cli#586 ·
Maintainers usually reply within 1 day
-
Difficulty 4/5 3-5 days Newbie friendliness 30/100
all-contributors/cli#584 ·
Maintainers usually reply within 1 day
-
[BUG]: Markdown provided in `types[key].link` is injected as-is into HTMLAnchorElement's href attributePossibly taken @theworker02 claimed this 33 days ago. Open
Difficulty 3/5 1-2 days Newbie friendliness 61/100
all-contributors/cli#520 · 1 comment ·
Maintainers usually reply within 1 day
-
Additional Config File OptionsMay be free again A pull request for this issue was closed without being merged. Open
Difficulty 3/5 1-2 days Newbie friendliness 68/100
all-contributors/cli#499 · 2 comments · 6 reactions ·
Maintainers usually reply within 1 day
-
Consider adding a PR title checker to enforce angular / conventional commitsMay be free again A pull request for this issue was closed without being merged. Opentype: ci type: enhancement type: infrastructure
Difficulty 2/5 1-3 hours Newbie friendliness 42/100
all-contributors/cli#482 · 3 comments · 1 reaction ·
Maintainers usually reply within 1 day
All issues in all-contributors/cli
Similar issues
-
ai-driven-fuzzing bug claude Minor
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
linagora/cozy-client#1777 · 1 comment · 1 reaction ·
Maintainers usually reply within 1 day
-
[guide] AGENTS.md claims the coverage gate, e2e and full lint run on every PR after ADR 0011 focused validationPossibly taken @hivecommons-hive claimed this today. Openagent/guide documentation hive/claimed-by-guide stage/040-covered-by-pr
Difficulty 2/5 1-3 hours Newbie friendliness 81/100
cncf/endusers#2006 · 1 comment ·
Maintainers usually reply within 1 day
-
check:passed feeds:add
Difficulty 2/5 1-3 hours Newbie friendliness 65/100
Maintainers usually reply within 4 days
-
CMS video element: "CmsVideoPlugin" sets `volume = 0`, so videos cannot be unmuted on Android ChromeOpenneeds-triage Platform(Default)
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
Maintainers usually reply within 1 day
-
RGAA5
Difficulty 2/5 1-3 hours Newbie friendliness 66/100
Maintainers usually reply within 8 days