danger / danger/peril

Getting wrong `danger` object when Peril runs a Dangerfile

Open
#431 10 comments 0 reactions 0 assignees View on GitHub
Dominant language
TypeScript
Stars
460
Forks
55
PR merge metrics
No merged PRs in 30d

Description

Hello, I've been trying to set up Peril locally by following [the docs](https://github.com/danger/peril/blob/master/docs/local_dev.md). Everything works fine until I try to run a Dangerfile.

I cloned the `danger/peril-settings` and did some small changes to the `settings.json` file, leaving only the `markAsMergeOnGreen.ts` and `mergeOnGreen.ts`.

When I get a github hook for a `issue_comment`, Peril tries to run the `markAsMergeOnGreen.ts` that I specified on my `settings.json`, but the `danger` object is not the [DangerDSL](https://github.com/danger/danger-js/blob/master/source/dsl/DangerDSL.ts), 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](https://developer.github.com/v3/activity/events/types/#issuecommentevent) 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:
```
yarn run v1.15.2
$ node out/index.js
info:
info: ☢️ Starting up Peril
info: ⅹ Papertrail
info: ⅹ Clustering
info: ✓ JSON Db at lalainc/peril-settings@settings.json
info: ✓ Server:
info: - Local: http://localhost:5000
[winston] Unknown logger level: router
info:
info: ## issue_comment.created on unknown on LalaInc/coindar-ios
info: 1 run needed: lalainc/peril-settings@org/markAsMergeOnGreen.ts
@babel/polyfill is loaded more than once on this page. This is probably not desirable/intended and may have consequences if different versions of the polyfills are applied sequentially. If you do need to load the polyfill more than once, use @babel/polyfill/noConflict instead to bypass the warning.
-- DANGERR ---------------
{ github:
{ action: 'created',
issue:
{ ... },
comment:
{ ... },
repository:
{ ... },
organization:
{ ... },
sender:
{ ... },
installation:
{ ... } } }
TypeError: Cannot read property 'orgs' of undefined
at Object.exports.default (/path/to/peril/api/danger-0.wfe3bdnkd99.ts:33:19)
at Object. (/path/to/peril/api/node_modules/danger/distribution/runner/runners/inline.js:147:60)
at step (/path/to/peril/api/node_modules/danger/distribution/runner/runners/inline.js:32:23)
at Object.next (/path/to/peril/api/node_modules/danger/distribution/runner/runners/inline.js:13:53)
at /path/to/peril/api/node_modules/danger/distribution/runner/runners/inline.js:7:71
at new Promise ()
at __awaiter (/path/to/peril/api/node_modules/danger/distribution/runner/runners/inline.js:3:12)
at Object.exports.runDangerfileEnvironment (/path/to/peril/api/node_modules/danger/distribution/runner/runners/inline.js:105:136)
at runDangerAgainstFileInline (/path/to/peril/api/out/danger/danger_runner.js:49:37)
at process._tickCallback (internal/process/next_tick.js:68:7)
Sender does not have permission to merge
```

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.