Skip to content

Getting wrong danger object when Peril runs a Dangerfile #431

@alephao

Description

@alephao

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 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, 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:

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.<anonymous> (/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 (<anonymous>)
    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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions