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

Undefined event name in webhook handler #12

Closed
iamogbz opened this issue Jan 14, 2019 · 7 comments · Fixed by #14
Closed

Undefined event name in webhook handler #12

iamogbz opened this issue Jan 14, 2019 · 7 comments · Fixed by #14

Comments

@iamogbz
Copy link

iamogbz commented Jan 14, 2019

Just started using probot and while debugging noticed this:

03:01:34.721Z DEBUG probot: Webhook received
event: {
  "event": "undefined.synchronize",
  "installation": 101010,
  "repository": "owner/repo"
}

Traced it to
https://github.com/probot/serverless-lambda/blob/ee2e66125b930552d647e12676ef98b19fe10688/index.js#L45

Github might have changed the headers sent because at some point my bot was working:

X-Github-Event: pull_request

Current header has a slight spelling difference.

EDIT: GitHub seems to have fixed the header issue in their request but making this more robust would still be a good idea.

@mrchief
Copy link
Contributor

mrchief commented Mar 6, 2019

In my case the header is X-GitHub-Event but I still get undefined.XXX. Not sure why this is happening.

@JasonEtco
Copy link
Member

Can y'all see what event.headers is? Does it contain any headers at all?

@mrchief
Copy link
Contributor

mrchief commented Mar 6, 2019

This is what I see in Cloudwatch logs

"event": {
        "event": "undefined.edited",
        "repository": "mrchief/githubActionsPoC"
    },

@iamogbz
Copy link
Author

iamogbz commented Mar 7, 2019

@JasonEtco it does contain headers. It's been a while but iirc, on the GitHub bot manage page the header sometimes gets displayed as X-GitHub-Event. Added logging of the raw event.headers received and X-Github-Event is shown. I could consistently reproduce that at some point.

@aweiher
Copy link

aweiher commented Mar 14, 2019

Got 'X-Github-Event': 'push' on GHE 2.16.4

@JasonEtco yes, content of event.headers (developing local with aws sam)

{ 
     Host: '127.0.0.1:3000',
     'User-Agent': 'insomnia/6.3.2',
     'Content-Type': 'application/json',
     'X-Github-Event': 'push',
     'X-Hub-Signature': 'sha1=b6443ae5abd9f8fea47e09ab4eb9b3d00616317b',
     'X-Github-Delivery': 'dd1c4022-4631-11e9-8c4d-7e06af5c5b2e',
     Accept: '*/*',
     'Content-Length': '8949',
     'X-Forwarded-Proto': 'http',
     'X-Forwarded-Port': '3000' 
} 

@tcbyrd
Copy link
Collaborator

tcbyrd commented Mar 16, 2019

X-Github-Event

Part of me just wants to figure out where the lowercase h is coming from and fix that, but #14 is probably the more robust path forward 😬

Will get that tested and pushed to npm. Thanks for the discussion and help fixing it everyone!

@mrchief
Copy link
Contributor

mrchief commented Mar 16, 2019

Http header names are case insensitive per the spec, so #14 is the way to go IMO

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

Successfully merging a pull request may close this issue.

5 participants