Skip to content
This repository has been archived by the owner on Feb 11, 2022. It is now read-only.

github webhook test returns 500 #122

Closed
mren opened this issue Nov 17, 2017 · 8 comments
Closed

github webhook test returns 500 #122

mren opened this issue Nov 17, 2017 · 8 comments

Comments

@mren
Copy link

mren commented Nov 17, 2017

Hello,

I managed to deploy the app to heroku. Unfortunately my github webhook test is throwing an error.

What I did

  • deployed app to heroku
  • I set the environment variables for the github access token secret and for the webhook secret
  • configured webhook with /payload path
  • run webhook test
2017-11-17T15:43:02.083606+00:00 heroku[router]: at=info method=POST path="/payload" host=fahrstundenplaner-greenkeeper.herokuapp.com request_id=2ac0a473-ddb1-495c-9b3e-7a2ef2e86172 fwd="192.30.252.34" dyno=web.1 connect=0ms service=48ms status=500 bytes=305 protocol=https
2017-11-17T15:43:02.088700+00:00 app[web.1]: 171117/154302.039, [error] message: Uncaught error: Cannot read property 'config' of undefined, stack: TypeError: Uncaught error: Cannot read property 'config' of undefined
2017-11-17T15:43:02.088715+00:00 app[web.1]:     at validatePayloadAndProcess (/app/node_modules/hapi-greenkeeper-keeper/lib/plugin.cjs.js:484:41)
2017-11-17T15:43:02.088716+00:00 app[web.1]:     at handler (/app/node_modules/hapi-greenkeeper-keeper/lib/plugin.cjs.js:541:7)
2017-11-17T15:43:02.088717+00:00 app[web.1]:     at Object.internals.handler (/app/node_modules/hapi/lib/handler.js:101:51)
2017-11-17T15:43:02.088718+00:00 app[web.1]:     at request._protect.run (/app/node_modules/hapi/lib/handler.js:32:23)
2017-11-17T15:43:02.088719+00:00 app[web.1]:     at module.exports.internals.Protect.internals.Protect.run (/app/node_modules/hapi/lib/protect.js:60:12)
2017-11-17T15:43:02.088720+00:00 app[web.1]:     at exports.execute (/app/node_modules/hapi/lib/handler.js:26:22)
2017-11-17T15:43:02.088721+00:00 app[web.1]:     at each (/app/node_modules/hapi/lib/request.js:401:16)
2017-11-17T15:43:02.088721+00:00 app[web.1]:     at iterate (/app/node_modules/items/lib/index.js:36:13)
2017-11-17T15:43:02.088722+00:00 app[web.1]:     at done (/app/node_modules/items/lib/index.js:28:25)
2017-11-17T15:43:02.088723+00:00 app[web.1]:     at internals.Auth.payload (/app/node_modules/hapi/lib/auth.js:248:16)
2017-11-17T15:43:02.090144+00:00 app[web.1]: Debug: internal, implementation, error 
2017-11-17T15:43:02.090145+00:00 app[web.1]:     TypeError: Uncaught error: Cannot read property 'config' of undefined
2017-11-17T15:43:02.090146+00:00 app[web.1]:     at validatePayloadAndProcess (/app/node_modules/hapi-greenkeeper-keeper/lib/plugin.cjs.js:484:41)
2017-11-17T15:43:02.090148+00:00 app[web.1]:     at Object.internals.handler (/app/node_modules/hapi/lib/handler.js:101:51)
2017-11-17T15:43:02.090147+00:00 app[web.1]:     at handler (/app/node_modules/hapi-greenkeeper-keeper/lib/plugin.cjs.js:541:7)
2017-11-17T15:43:02.090149+00:00 app[web.1]:     at request._protect.run (/app/node_modules/hapi/lib/handler.js:32:23)
2017-11-17T15:43:02.090149+00:00 app[web.1]:     at module.exports.internals.Protect.internals.Protect.run (/app/node_modules/hapi/lib/protect.js:60:12)
2017-11-17T15:43:02.090150+00:00 app[web.1]:     at exports.execute (/app/node_modules/hapi/lib/handler.js:26:22)
2017-11-17T15:43:02.090151+00:00 app[web.1]:     at each (/app/node_modules/hapi/lib/request.js:401:16)
2017-11-17T15:43:02.090151+00:00 app[web.1]:     at iterate (/app/node_modules/items/lib/index.js:36:13)
2017-11-17T15:43:02.090152+00:00 app[web.1]:     at done (/app/node_modules/items/lib/index.js:28:25)
2017-11-17T15:43:02.090153+00:00 app[web.1]:     at internals.Auth.payload (/app/node_modules/hapi/lib/auth.js:248:16)
2017-11-17T15:43:02.092499+00:00 app[web.1]: 171117/154302.039, [response] http://147fd646-23fa-4d6e-bbba-52138203de09:47793: post /payload {} 500 (52ms)

Any idea what I did wrong?

@travi
Copy link
Member

travi commented Jan 28, 2018

i'm so sorry that i havent responded to this issue yet. somehow i completely missed the notification for it when you posted it. did you end up having any luck resolving the problem? which version were you running at the time? do you still have the problem with the latest version?

@travi
Copy link
Member

travi commented Jan 28, 2018

my best guess is that the webhook was being sent as application/x-www-form-encoded instead of application/json. if you changed this in the webhook settings for the repo you are wanting to trigger the greenkeeper-keeper behavior for, it should work better.

if you're still interested in getting this working, please let me know if this does this trick. this has caught me a number of times in the past since it is the default choice when you set up the webhook. i thought this was documented, but somehow it was not, so i added a note about it in the steps for setting up webhooks

unfortunately, the handling of this situation isn't working as intended currently. while i coded it to respond with a helpful message, i have an open issue to fix because the incoming request isn't parsed correctly, so it fails to get to that helpful hint.

@mren
Copy link
Author

mren commented Feb 6, 2018

Hey travi,

thanks for reaching out. I think you are right. I changed the webhook to json and now the app is not crashing. Thanks for adding this information to the README.

I just looked into the logs and I received a few requests, which did not crash :)
However I am a bit confused if the requests had been successful. All requests receive a 4xx status response.

Feb 06 00:28:10 heroku-app-greenkeeper heroku/router: at=info method=POST path="/payload" host=heroku-app-greenkeeper.herokuapp.com request_id=aa95175b-6204-4826-9cf9-139d798b3cd0 fwd="192.30.253.29" dyno=web.1 connect=0ms service=28ms status=400 bytes=199 protocol=https 
Feb 06 00:28:10 heroku-app-greenkeeper app/web.1: 180206/082810.238, (1517905690222:bf19439d-b381-4bfe-8e62-1557501f646e:20:jdbdutvd:10000) [request,PR,skipping] data: (none) 
Feb 06 00:28:10 heroku-app-greenkeeper app/web.1: 180206/082810.222, [response] http://bf19439d-b381-4bfe-8e62-1557501f646e:43797: post /payload {} 400 (28ms) <Paste>

Is this a correct response? Can I find some documentation about the different request flows, so I can verify the correctness of the setup?

Edit:
Can I enable more detailed logging?

@travi
Copy link
Member

travi commented Feb 8, 2018

unfortunately, i have not gotten around to adding more detail to the response for why the webhook was skipped, so there isn't much beyond what you are already digging into. if you're interested in sending a PR to add more detailed logs, i'd be happy to work through it with you.

the one other place worth digging into that could provide some insight before we get to the point of modifying code is the list of responses captured by github for the webhook definition. if you go back to where you set up the webhook (repo settings > webhook > your webhook) and scroll down past the webhook definition details, you'll find the list of responses.

assuming you configured github to send the status even webhooks, as recommended, greenkeeper-keeper will return a 202 response for status events that have all successful commit checks. however, if one of the checks is not successful, or the PR was not from greenkeeper, it will return a 400. since the log you show above shows a 400 status, it is from here, confirming that one of the initial checks failed for that event.

it is quite common to get several 400 responses before a 202, though, because this logic is evaluated for every commit status change. if you have more checks registered against your repos, more status events will fire, and these checks will fail until all of the checks have changed to success. once they all change to success, greenkeeper-keeper will continue through the process to actually accept the PR.

from the log you show above, it isn't (yet, at least) getting to the point of trying to accept. if you look at the list of responses, are you getting any 202 responses after the 400s? is greenkeeper-keeper adding comments to the PR?

@travi
Copy link
Member

travi commented Feb 8, 2018

thank you for continuing to ask about documentation. i'm certain we can get through any issues you might have remaining, but it will have to be fairly manual for now.

even with good intentions, i havent gotten some of this stuff documented as well as i'd like. i might not get this done right away, but i have at least added an issue for documenting the basic flow with some debugging hints so that i remember to get back to that sometime.

i would certainly like to make this process smoother for others in the future. working through these types of issues highlights the gaps that i havent closed yet since i've already become a bit blind to them.

again, thanks for the nudge.

@mren
Copy link
Author

mren commented Feb 8, 2018

Nice, it is working. It already merged 2 patches. Thank you for this great product.

Maybe you are right and there is no need for addiitonal logging.
I would suggest to add the description you gave me to the readme.
Then it will be more clear what to expect and how to validate the project.

Thanks for helping me with setting the project up.

@mren mren closed this as completed Feb 8, 2018
@travi
Copy link
Member

travi commented Feb 8, 2018

awesome. glad its working!

agreed on the readme updates, i'll be sure to get something better out there once i get some time to sit down and write out a quick flow outline.

thanks so much for giving greenkeeper-keeper a try and dont hesitate to file issues if you see ways it could improve. my availability is pretty limited, but i do find time here and there to keep it moving forward.

also, don't hesitate to bump the thread if i dont at least respond. sorry again that it took me so long to spot these. i'm normally pretty on top of notifications, so i don't know how i missed them.

@mren
Copy link
Author

mren commented Feb 8, 2018

sure, thank you for this awesome project!

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants