-
Notifications
You must be signed in to change notification settings - Fork 58
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Getting 'TypeError: danger.git.JSONDiffForFile is not a function' #367
Comments
Hrm, interesting, offhand - no, we have every PR running: const path = options.pathToPackageJSON ? options.pathToPackageJSON : "package.json"
const packageDiff = await danger.git.JSONDiffForFile(path)
checkForRelease(packageDiff)
checkForLockfileDiff(packageDiff)
checkForTypesInDeps(packageDiff) via danger-plugin-yarn on the artsy org. What happens when you print out |
The output is
which looks the fields defined in the |
What event is this coming from? ( wondering about #343 ) |
It's a |
I am also seeing this issue, with the following rule:
This is the error I see:
I will look into this and post back if I find a way to solve or work around it. |
My gut is that somehow Peril thinks this run is for an event and not a PR - https://github.com/danger/peril/blob/master/api/source/github/events/github_runner.ts#L177-L192 |
That's an interesting thought! If that is the case shouldn't many more things be breaking? e.g. |
Could this be some kind of configuration issue? The Github App has Read & Write permissions for "Checks", "Issues", "Pull Requests" and "Commit Statuses". Should it also have permission for "Repository contents" or similar? |
Thanks, @orta. I have tried adding just "Repository Contents" and also matching your settings (even though its overkill) and unfortunately it didn't help the issue - I restarted the Heroku app after the changes. As with @svenmuennich, the event seems to be pull_request.synchronize. Here is the log when it happens:
|
Can you verify if I think it's because this line in an even passes in the JSON DSL, not the full DSL (with functions etc) which would only happen if somehow Peril thinks it has an event https://github.com/danger/peril/blob/master/api/source/runner/run.ts#L85 |
Yes, it does exist. I added these two lines:
And got this output:
|
I have managed to work around this issue for my particular case by changing the above rule to:
Since I'll be happy to help track this down though if there is anything I can do. |
OK, well, I think that knocks that idea out that it's the JSON version of the entire Github + git DSL being used. Tricky tricky, haven't found anything so far |
Yeah, it does seem strange. Could it be an ES6 problem since those methods are added using I'm probably grasping at straws but its the only idea I can think of. My JS knowledge isn't very deep. |
No worries, those are the type definitions (think .h files) - which don't really affect runtime behavior. I avoid classes in ES6, Somehow the function here isn't getting called: |
Oh, that's interesting. Thanks for the context! |
I'm seeing another very similar issue now that I have updated to On master (4c54ab9),
On the commit I have reverted to (b0d8bdb), it gives:
This may be a danger-js issue, which was updated from 6.0.9 . to 7.1.9 between these commits. Update: I have confirmed that this was introduced when danger was updated to 7.1.9 prior to the mono repo change (0346e66). |
Interesting! So the reason I major semver bumped was because it updated the GitHub API client (which could break dangerfiles) but that shouldn't be causing this |
@jtreanor I'm trying to get peril setup for our org and running into the same issue you've described here. What commitsha of peril did you end up deploying that gives you access to be able to get files usign Want to get something up and running and then can help debug on my own time :) |
thank you! do you happen to have an open copy of hwo you are running async functions with that version. I keep getting |
@roopakv All of the Peril settings I am using are in this repo: https://github.com/wordpress-mobile/peril-settings. I hope thats helpful! |
Was this by chance also fixed with #436 ? |
@roopakv No, it wasn't unfortunately. I'm currently investigating it. |
I have put together a fix for this in #439. PR runs were not using the full DSL so I have fixed that. |
When running a dangerfile containing a call to
danger.git.JSONDiffForFile()
on peril the following error is thrown:Here's an example dangerfile that should trigger the error.
Running the same dangerfile locally using the
danger pr
command works without error. We use the current latest commit ofmaster
(9b835cb). My local danger version is3.8.8
.Is there any reason why
JSONDiffForFile()
would not be available in the objectdanger.git
?The text was updated successfully, but these errors were encountered: