gith icon indicating copy to clipboard operation
gith copied to clipboard

Gith responding to github with status 200 but callback not called.

Open joshjhargreaves opened this issue 10 years ago • 12 comments

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

joshjhargreaves avatar Aug 20 '14 11:08 joshjhargreaves

I am also noticing this issue.

drGrove avatar Aug 21 '14 01:08 drGrove

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) );

dneff avatar Aug 26 '14 06:08 dneff

+1 on seeing the same behaviour.

Can also confirm the above comment fixes the issue.

gauntface avatar Sep 02 '14 21:09 gauntface

+1 for fixing this

emanuil avatar Dec 17 '14 15:12 emanuil

I'm still seeing this.

billautomata avatar Jan 07 '15 23:01 billautomata

Same here. Seems like a project is dead...

robhrt7 avatar Jan 20 '15 17:01 robhrt7

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

murphyj avatar Feb 07 '15 22:02 murphyj

Are use using the correct content type ? image

dcharbonnier avatar Feb 14 '15 17:02 dcharbonnier

@dcharbonnier changing to that content type seems to work correctly. Though I would think this should work with the default settings on github.

itsamenathan avatar Feb 17 '15 18:02 itsamenathan

@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?

murphyj avatar Mar 03 '15 17:03 murphyj

If gith doesn't properly handle the format, it should return an appropriate status code, or at least provide some sort of feedback.

nicbou avatar Aug 21 '15 09:08 nicbou

I was also having trouble with this. Changing the content type to application/x-www-form-urlencoded fixed this issue! Thanks @dcharbonnier

maximilliangeorge avatar Nov 04 '15 11:11 maximilliangeorge