Incorrect command execution behavior when `rules.exec` is an array
Nobody has claimed this yet.
- Dominant language
- JavaScript
- Stars
- 115
- Forks
- 23
- Avg merge
- 3d 5h
- Merged PRs (30d)
- 3
Description
The code pops the first element of an array in each execution and the length of the array is reduced by one each time when the webhook is triggered since the array is passed by reference in the code.
For example, consider the config shown as following:
{
"port": 8080,
"path": "/postreceive",
"secret": "0123456789abcdef",
"rules": [{
"event": "push",
"exec": ["foo", "bar", "baz"]
}]
}
When the webhook is triggered for the first time, foo bar baz is executed. For the second time, the command will be bar baz, and baz for the third time, and then an error is thrown for the fourth time since the array is empty and nothing can be popped.
The simplest solution might be copying the array instead of passing by reference.
Contributor guide
No contributing guide indexed for this repository
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.
Research direction
Start in github-webhook.js at lines 202 and 206, then reproduce the example configuration with repeated push webhook executions. Verify that the configured exec array is not shortened between triggers: each run should execute the original foo bar baz command and should not fail after the array has been consumed.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript
- Domain
- backend
- Issue type
- Bug
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 55/100