gith
gith copied to clipboard
Gith responding to github with status 200 but callback not called.
I have beem attempting to implement git hooks with gith have had no luck. Even the very simple example below does not behave as I would expect. Status code 200 is being returned to github, so the gith server is obviously running, but the callback is not ever being called.
var gith = require('gith').create(9004); // ensure to match the port you entered in Github
gith().on( 'all', function( payload ) {
console.log( 'Post-receive happened!' );
});
For the record I'm using Ubuntu 14.04 x64
I am also noticing this issue.
I ran into this issue when using github enterprise. I'm also using Ubuntu 14.04.
I'm not sure if the webhooks are formatted differently for GH:E, but in digging through the lib/gith.js
, it looks like these lines (starting at 247) are the problem:
if ( /^payload=/.test( data ) ) {
var payload = JSON.parse( querystring.unescape(data.slice(8)) );
There is no payload=
in my webhook response, so I changed it to this:
if ( data ) {
var payload = JSON.parse( querystring.unescape(data) );
after that, it works great. Perhaps the solution is to test for payload=
and trim it conditionally:
if ( data ) {
data = data.replace(/^payload=/,"");
var payload = JSON.parse( querystring.unescape(data) );
+1 on seeing the same behaviour.
Can also confirm the above comment fixes the issue.
+1 for fixing this
I'm still seeing this.
Same here. Seems like a project is dead...
I'm also seeing this problem. Github is telling me it's fired correctly and i'm definitely listening to the push event but it's not logging out. I'm also using Ubuntu 14.04
Are use using the correct content type ?
@dcharbonnier changing to that content type seems to work correctly. Though I would think this should work with the default settings on github.
@dcharbonnier thanks for getting back to me. I couldn't get it working so I opted for a much simpler hand-crafted Sinatra app.
Out of interest what's the benefit of using gith over something like a lightweight Sinatry app aside from the fact that you don't have to ensure a separate process is running?
If gith doesn't properly handle the format, it should return an appropriate status code, or at least provide some sort of feedback.
I was also having trouble with this. Changing the content type to application/x-www-form-urlencoded fixed this issue! Thanks @dcharbonnier