Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
joshjhargreaves opened this issue Aug 20, 2014 · 12 comments
Open

Comments

@joshjhargreaves
Copy link

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

@drGrove
Copy link

drGrove commented Aug 21, 2014

I am also noticing this issue.

@dneff
Copy link

dneff commented Aug 26, 2014

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

@gauntface
Copy link

+1 on seeing the same behaviour.

Can also confirm the above comment fixes the issue.

@emanuil
Copy link

emanuil commented Dec 17, 2014

+1 for fixing this

@billautomata
Copy link

I'm still seeing this.

@robhrt7
Copy link

robhrt7 commented Jan 20, 2015

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

@murphyj
Copy link

murphyj commented Feb 7, 2015

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

@dcharbonnier
Copy link

Are use using the correct content type ?
image

@itsamenathan
Copy link

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

@murphyj
Copy link

murphyj commented Mar 3, 2015

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

@nicbou
Copy link

nicbou commented Aug 21, 2015

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

@maximilliangeorge
Copy link

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

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

No branches or pull requests