Closed spinx closed 5 years ago
Interesting, the only times the length is used in the Executor is on the different attributes of fails
, markdowns
, messages
and warnings
- so somehow that's being corrupted in there?
Going through the generated JS it actually fails on this: https://github.com/danger/danger-js/blob/7.0.19/source/runner/Executor.ts#L279
git is undefined at this point
locally danger posts to github just fine, but that's with my token not via github app
I believe I am seeing the same issue with a brand new Github app with very simple settings.
peril-setings.json
:
{
"rules": {
"pull_request, pull_request.labeled, pull_request.unlabeled": "rules.ts"
}
}
rules.ts
:
import {warn} from "danger";
warn("Test warning");
When master (b69e580b34afb12f8b08340e1094879969fb4d25) is deployed to Heroku or when running locally, I'm getting this crash:
error: UnhandledRejection Error: Cannot read property 'length' of undefined {"stack":"TypeError: Cannot read property 'length' of undefined\n at Executor.<anonymous> (/Users/james/src/peril/api/node_modules/danger/distribution/runner/Executor.js:309:60)\n at step (/Users/james/src/peril/api/node_modules/danger/distribution/runner/Executor.js:32:23)\n at Object.next (/Users/james/src/peril/api/node_modules/danger/distribution/runner/Executor.js:13:53)\n at fulfilled (/Users/james/src/peril/api/node_modules/danger/distribution/runner/Executor.js:4:58)\n at process._tickCallback (internal/process/next_tick.js:68:7)"}
/Users/james/src/peril/api/out/peril.js:24
throw reason;
^
TypeError: Cannot read property 'length' of undefined
at Executor.<anonymous> (/Users/james/src/peril/api/node_modules/danger/distribution/runner/Executor.js:309:60)
at step (/Users/james/src/peril/api/node_modules/danger/distribution/runner/Executor.js:32:23)
at Object.next (/Users/james/src/peril/api/node_modules/danger/distribution/runner/Executor.js:13:53)
at fulfilled (/Users/james/src/peril/api/node_modules/danger/distribution/runner/Executor.js:4:58)
at process._tickCallback (internal/process/next_tick.js:68:7)
Using git bisect
, I have confirmed that the breaking change was made when Danger was updated to 7.0.9 in 66b415e. The temporary solution is to use an old version, but I would really like to get to the bottom of this.
Is there any other info I can give to help with debugging? The Github app is set up exactly as described in the guide so this seems to be as stock as a setup could be unless I'm missing something.
Could this be related to the other issue I reported in https://github.com/danger/peril/issues/367#issuecomment-467363340? It was also introduced by the Danger update.
I'll keep digging.
This line was added to Executor.js
in the Danger update (see https://github.com/danger/danger-js/compare/6.1.9...7.0.9#diff-bb13471af891e272bfdbcaee1d82a94dR269):
const commitID = git.commits[git.commits.length - 1].sha
It looks like this may be the line that it's crashing on. So git.commits
appears to be undefined here. This matches what @spinx observed above.
I have tried adding console.log(danger.git.commits);
to my rules file and it does give a list of commits as expected.
As @jtreanor pointed out it works with danger@6.1.9
. Looking at the code I found this line and it looks like it could be related to 66b415e
mentioned above (commenting.ts, danger_runner.ts)
The root cause of this crash is that Peril does not have a GitDSL
object to pass to Danger, but handleResults
requires it. I have opened a PR to make this parameter optional in Danger.js here: https://github.com/danger/danger-js/pull/887.
Alright, Peril is now up to date with the changes in Danger JS in master ^
Great!
The PR to close this is here: https://github.com/danger/peril/pull/438
I have tested it and I'm not seeing the crash anymore 🎉
Hey,
I've been trying to debug this one myself and getting nowhere. It's probably something really trivial 😬
The same happens for Peril hosted on Heroku and development version via ngrok. Deployed latest master@ff390dc65b4561634ffae56f10fa3a52265afdf3
Github app only has access to a few repos in the org. I tried granting all permissions on dev so it's not that.
Peril settings file:
dangerfile.ts:
Peril crashes out with this error after dangerfile is evaluated:
Any idea what this could be ?