Skip to content

Github webhook: fails to retrieve req.Body #137

Closed
rafecolton/vauth
#2

Description

@wjzijderveld

Having an issue and can't seem to find a fix or a way around this.

I'm trying to setup the Github webhook, but I keep getting the error: ERRO[0005] unexpected end of JSON input

It fails in json.Unmarshal, but when I refactor to use something like here I get an error 'EOF' (really, thats the complete error 😕)

I read somewhere that the Body will be unavailable when the Request has been closed already, which happens when something gets returned. But I can't seem to find what actually goes wrong.

As I use the github hook, the vauth stuff already happened there, so it has read the Body already: https://github.com/rafecolton/vauth/blob/3c5da807bc47903e09eba6d4efef3cd9ad916851/github.go#L21

Might that be the problem? That you can't read the Body twice? (Seems odd, but just thinking out loud)

Activity

  1. wjzijderveld commented on Oct 6, 2014

    @wjzijderveld
    Author

    Just tested this without --github-secret, and then it actually does work as expected...

  2. rafecolton commented on Oct 6, 2014

    @rafecolton
    Owner

    Hm, this is a strange one. From the net/http documentation,

        // For server requests the Request Body is always non-nil
        // but will return EOF immediately when no body is present.
    

    So that could explain the EOF but not why there is no body present. It also doesn't explain why it would work as expected when --github-secret is not provided, as the body would still get read once by vauth. As far as I can tell, if this were due to the body being closed we would see this error, which we are not.

    I'll look in to this, and any other information you run across would (or a pull request if you find a fix) would be extremely helpful.

  3. rafecolton commented on Oct 30, 2014

    @rafecolton
    Owner

    @wjzijderveld I have a fix for this, will submit a pull request shortly. Thanks for your patience!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions

      ⌂ 换网址