-
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 wrong danger
object when Peril runs a Dangerfile
#431
Comments
For non-PR events you don't get the DangerDSL (because the DSL is built for PRs (and while some issues are PRs, there are many which aren't)) In those cases you get a lot of the utils options but nothing specific to a PR etc, but I mostly use I should probably find a way to document what's available at some point - yep |
Hmm, so Because what I get on |
Yeah, that sounds like a weird bug - we have lots of code which relies on https://github.com/artsy/peril-settings/blob/master/org/markAsMergeOnGreen.ts#L5-L8 |
Yea, I was trying to use markAsMergeOnGreen. This bug happens consistently to me when running locally, not sure what could be causing it |
Maybe try adding some logs around here: https://github.com/danger/peril/blob/master/api/source/runner/run.ts#L83-L90 I know in old versions of Peril I used to put the JSON payload inside |
I am able to reproduce. I think I have root caused the issue: peril/api/source/github/events/handlers/event.ts Lines 29 to 32 in 45854ce
When an event comes in that is not commentable the githubAPI is not created. This in turn means that the api and util objects do not get create for the dangerDSL that gets exposed to the inline dangerfile. That causes the error that repos cannot be called on undefined object. |
@orta I added some logs to this function, and It doesn't seem like this function is being called at all 🤔 @adam-bratin, I looked into it and peril/api/source/danger/danger_run.ts Lines 187 to 192 in 45854ce
But not sure if that's the issue. I tried forcing it to return a |
(Just letting you folks I'm not ignoring you, this is my last week at Artsy and I don't really have any spare time to think about maintaining OSS stuff ATM) FWIW, the GitHubAPI object (from DangerJS) vs the OctoKit API are different things - I'd expect the GitHubAPI to be missing on any non-issue event because it needs to have a commentable thing to work with. I would hope this shouldn't affect the creation of ta GitHubDSL object- but it could be that, yep |
Hey @orta no problem real life happens. Just to give you some more context:
//where req.body is the payload of the event and becomes dangerDSL in runEventRun
await runEventRun(eventName, eventRuns, settings, token, req.body)
//(remember dangerDSL is still event details)
{ dsl: { github: dangerDSL }
//(dangerDSL still event details)
{ dsl: { github: dangerDSL }, webhook: dangerDSL }
//danger is still event details
{
schedule,
fail,
warn,
message,
markdown,
results,
danger: dsl,
peril: {} as any,
}
This is the overall path of how danger.github.api is undefined |
@orta any update on this? |
Hello, I've been trying to set up Peril locally by following the docs. Everything works fine until I try to run a Dangerfile.
I cloned the
danger/peril-settings
and did some small changes to thesettings.json
file, leaving only themarkAsMergeOnGreen.ts
andmergeOnGreen.ts
.When I get a github hook for a
issue_comment
, Peril tries to run themarkAsMergeOnGreen.ts
that I specified on mysettings.json
, but thedanger
object is not the DangerDSL, which is what I'm expecting.I added a
console.log(danger)
on the dangerfile, and found out that the object was actually a IssueCommentEvent payload as I show in the logs below.Not sure if that's a bug or if I'm doing something very wrong. Can someone give me a light?
Thank you!
Logs:
The text was updated successfully, but these errors were encountered: