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

400 Invalid JSON in response from GitHub hooks #75

Closed
YChebotaev opened this issue Apr 20, 2019 · 8 comments
Closed

400 Invalid JSON in response from GitHub hooks #75

YChebotaev opened this issue Apr 20, 2019 · 8 comments
Labels
Type: Support Any questions, information, or general needs around the SDK or GitHub APIs

Comments

@YChebotaev
Copy link

This is what GitHub tells me: https://ibb.co/Cmw9wBp

My setup: https://gist.github.com/YChebotaev/ecd701c195fa4bd1383126969336bdda

Help, please.

@YChebotaev YChebotaev changed the title webhooks not working 400 Invalid JSON in response from GitHub hooks Apr 20, 2019
@gr2m
Copy link
Contributor

gr2m commented Apr 21, 2019

What was the request headers and payload?

@gr2m gr2m added the Type: Support Any questions, information, or general needs around the SDK or GitHub APIs label Apr 21, 2019
@YChebotaev
Copy link
Author

@gr2m
Request header:

Request URL: https://prizmo-webhooks.prizmo.tech/webhooks/github
Request method: POST
content-type: application/x-www-form-urlencoded
Expect: 
User-Agent: GitHub-Hookshot/b9517ca
X-GitHub-Delivery: cbbcc566-63d9-11e9-9dc2-8901b1d8e691
X-GitHub-Event: push
X-Hub-Signature: sha1=457b750fe3a2bb8f2d53393b9a7199f69e5f3e2f

Payload:

{
  "ref": "refs/heads/master",
  "before": "b633938b836945c5cd5db895b7d631223d0cbde7",
  "after": "8faa98ea3fa235415d4c0400376bbe0995b9e995",
  "created": false,
  "deleted": false,
  "forced": false,
  "base_ref": null,
  "compare": "https://github.com/YChebotaev/prizmo/compare/b633938b8369...8faa98ea3fa2",
  "commits": [
    {
      "id": "8faa98ea3fa235415d4c0400376bbe0995b9e995",
      "tree_id": "c521ac55c8c0c0fc85af51ef841b3e4b307ff65e",
      "distinct": true,
      "message": "Добавил процедуру удаления конверсий",
      "timestamp": "2019-04-21T07:04:21+05:00",
      "url": "https://github.com/YChebotaev/prizmo/commit/8faa98ea3fa235415d4c0400376bbe0995b9e995",
      "author": {
        "name": "Yury Chebotaev",
        "email": "yury.79120345101@gmail.com",
        "username": "YChebotaev"
      },
      "committer": {
        "name": "Yury Chebotaev",
        "email": "yury.79120345101@gmail.com",
        "username": "YChebotaev"
      },
      "added": [
        "packages/prizmo-service/clickhouse.js"
      ],
      "removed": [

      ],
      "modified": [
        "packages/prizmo-service/jobs.js",
        "packages/prizmo-service/lib/classes/TrackConversion.js",
        "packages/prizmo-service/models/schema/conversion.js",
        "packages/prizmo-service/package-lock.json",
        "packages/prizmo-service/package.json"
      ]
    }
  ],
  "head_commit": {
    "id": "8faa98ea3fa235415d4c0400376bbe0995b9e995",
    "tree_id": "c521ac55c8c0c0fc85af51ef841b3e4b307ff65e",
    "distinct": true,
    "message": "Добавил процедуру удаления конверсий",
    "timestamp": "2019-04-21T07:04:21+05:00",
    "url": "https://github.com/YChebotaev/prizmo/commit/8faa98ea3fa235415d4c0400376bbe0995b9e995",
    "author": {
      "name": "Yury Chebotaev",
      "email": "yury.79120345101@gmail.com",
      "username": "YChebotaev"
    },
    "committer": {
      "name": "Yury Chebotaev",
      "email": "yury.79120345101@gmail.com",
      "username": "YChebotaev"
    },
    "added": [
      "packages/prizmo-service/clickhouse.js"
    ],
    "removed": [

    ],
    "modified": [
      "packages/prizmo-service/jobs.js",
      "packages/prizmo-service/lib/classes/TrackConversion.js",
      "packages/prizmo-service/models/schema/conversion.js",
      "packages/prizmo-service/package-lock.json",
      "packages/prizmo-service/package.json"
    ]
  },
  "repository": {
    "id": 181070893,
    "node_id": "MDEwOlJlcG9zaXRvcnkxODEwNzA4OTM=",
    "name": "prizmo",
    "full_name": "YChebotaev/prizmo",
    "private": true,
    "owner": {
      "name": "YChebotaev",
      "email": "yury.79120345101@gmail.com",
      "login": "YChebotaev",
      "id": 5302856,
      "node_id": "MDQ6VXNlcjUzMDI4NTY=",
      "avatar_url": "https://avatars3.githubusercontent.com/u/5302856?v=4",
      "gravatar_id": "",
      "url": "https://api.github.com/users/YChebotaev",
      "html_url": "https://github.com/YChebotaev",
      "followers_url": "https://api.github.com/users/YChebotaev/followers",
      "following_url": "https://api.github.com/users/YChebotaev/following{/other_user}",
      "gists_url": "https://api.github.com/users/YChebotaev/gists{/gist_id}",
      "starred_url": "https://api.github.com/users/YChebotaev/starred{/owner}{/repo}",
      "subscriptions_url": "https://api.github.com/users/YChebotaev/subscriptions",
      "organizations_url": "https://api.github.com/users/YChebotaev/orgs",
      "repos_url": "https://api.github.com/users/YChebotaev/repos",
      "events_url": "https://api.github.com/users/YChebotaev/events{/privacy}",
      "received_events_url": "https://api.github.com/users/YChebotaev/received_events",
      "type": "User",
      "site_admin": false
    },
    "html_url": "https://github.com/YChebotaev/prizmo",
    "description": null,
    "fork": false,
    "url": "https://github.com/YChebotaev/prizmo",
    "forks_url": "https://api.github.com/repos/YChebotaev/prizmo/forks",
    "keys_url": "https://api.github.com/repos/YChebotaev/prizmo/keys{/key_id}",
    "collaborators_url": "https://api.github.com/repos/YChebotaev/prizmo/collaborators{/collaborator}",
    "teams_url": "https://api.github.com/repos/YChebotaev/prizmo/teams",
    "hooks_url": "https://api.github.com/repos/YChebotaev/prizmo/hooks",
    "issue_events_url": "https://api.github.com/repos/YChebotaev/prizmo/issues/events{/number}",
    "events_url": "https://api.github.com/repos/YChebotaev/prizmo/events",
    "assignees_url": "https://api.github.com/repos/YChebotaev/prizmo/assignees{/user}",
    "branches_url": "https://api.github.com/repos/YChebotaev/prizmo/branches{/branch}",
    "tags_url": "https://api.github.com/repos/YChebotaev/prizmo/tags",
    "blobs_url": "https://api.github.com/repos/YChebotaev/prizmo/git/blobs{/sha}",
    "git_tags_url": "https://api.github.com/repos/YChebotaev/prizmo/git/tags{/sha}",
    "git_refs_url": "https://api.github.com/repos/YChebotaev/prizmo/git/refs{/sha}",
    "trees_url": "https://api.github.com/repos/YChebotaev/prizmo/git/trees{/sha}",
    "statuses_url": "https://api.github.com/repos/YChebotaev/prizmo/statuses/{sha}",
    "languages_url": "https://api.github.com/repos/YChebotaev/prizmo/languages",
    "stargazers_url": "https://api.github.com/repos/YChebotaev/prizmo/stargazers",
    "contributors_url": "https://api.github.com/repos/YChebotaev/prizmo/contributors",
    "subscribers_url": "https://api.github.com/repos/YChebotaev/prizmo/subscribers",
    "subscription_url": "https://api.github.com/repos/YChebotaev/prizmo/subscription",
    "commits_url": "https://api.github.com/repos/YChebotaev/prizmo/commits{/sha}",
    "git_commits_url": "https://api.github.com/repos/YChebotaev/prizmo/git/commits{/sha}",
    "comments_url": "https://api.github.com/repos/YChebotaev/prizmo/comments{/number}",
    "issue_comment_url": "https://api.github.com/repos/YChebotaev/prizmo/issues/comments{/number}",
    "contents_url": "https://api.github.com/repos/YChebotaev/prizmo/contents/{+path}",
    "compare_url": "https://api.github.com/repos/YChebotaev/prizmo/compare/{base}...{head}",
    "merges_url": "https://api.github.com/repos/YChebotaev/prizmo/merges",
    "archive_url": "https://api.github.com/repos/YChebotaev/prizmo/{archive_format}{/ref}",
    "downloads_url": "https://api.github.com/repos/YChebotaev/prizmo/downloads",
    "issues_url": "https://api.github.com/repos/YChebotaev/prizmo/issues{/number}",
    "pulls_url": "https://api.github.com/repos/YChebotaev/prizmo/pulls{/number}",
    "milestones_url": "https://api.github.com/repos/YChebotaev/prizmo/milestones{/number}",
    "notifications_url": "https://api.github.com/repos/YChebotaev/prizmo/notifications{?since,all,participating}",
    "labels_url": "https://api.github.com/repos/YChebotaev/prizmo/labels{/name}",
    "releases_url": "https://api.github.com/repos/YChebotaev/prizmo/releases{/id}",
    "deployments_url": "https://api.github.com/repos/YChebotaev/prizmo/deployments",
    "created_at": 1555097099,
    "updated_at": "2019-04-21T01:37:48Z",
    "pushed_at": 1555812268,
    "git_url": "git://github.com/YChebotaev/prizmo.git",
    "ssh_url": "git@github.com:YChebotaev/prizmo.git",
    "clone_url": "https://github.com/YChebotaev/prizmo.git",
    "svn_url": "https://github.com/YChebotaev/prizmo",
    "homepage": null,
    "size": 1279,
    "stargazers_count": 0,
    "watchers_count": 0,
    "language": "JavaScript",
    "has_issues": false,
    "has_projects": false,
    "has_downloads": true,
    "has_wiki": false,
    "has_pages": false,
    "forks_count": 0,
    "mirror_url": null,
    "archived": false,
    "disabled": false,
    "open_issues_count": 0,
    "license": null,
    "forks": 0,
    "open_issues": 0,
    "watchers": 0,
    "default_branch": "master",
    "stargazers": 0,
    "master_branch": "master"
  },
  "pusher": {
    "name": "YChebotaev",
    "email": "yury.79120345101@gmail.com"
  },
  "sender": {
    "login": "YChebotaev",
    "id": 5302856,
    "node_id": "MDQ6VXNlcjUzMDI4NTY=",
    "avatar_url": "https://avatars3.githubusercontent.com/u/5302856?v=4",
    "gravatar_id": "",
    "url": "https://api.github.com/users/YChebotaev",
    "html_url": "https://github.com/YChebotaev",
    "followers_url": "https://api.github.com/users/YChebotaev/followers",
    "following_url": "https://api.github.com/users/YChebotaev/following{/other_user}",
    "gists_url": "https://api.github.com/users/YChebotaev/gists{/gist_id}",
    "starred_url": "https://api.github.com/users/YChebotaev/starred{/owner}{/repo}",
    "subscriptions_url": "https://api.github.com/users/YChebotaev/subscriptions",
    "organizations_url": "https://api.github.com/users/YChebotaev/orgs",
    "repos_url": "https://api.github.com/users/YChebotaev/repos",
    "events_url": "https://api.github.com/users/YChebotaev/events{/privacy}",
    "received_events_url": "https://api.github.com/users/YChebotaev/received_events",
    "type": "User",
    "site_admin": false
  }
}

@gr2m
Copy link
Contributor

gr2m commented Apr 22, 2019

Why did you add

  webhooks.on('*', ({ id, name, signature, payload }) => {
    await webhooks.verifyAndReceive({
      id,
      name,
      signature,
      payload
    })
  })

That’s already implemented in @octokit/webhooks/middleware

return verifyAndReceive(state, {
id: id,
name: eventName,
payload,
signature

I don’t think it is the problem here, but worth a try

@YChebotaev
Copy link
Author

@gr2m I'm removed this section, but it does not help.

@YChebotaev
Copy link
Author

@gr2m Why You just +1 for my comment?

@gr2m
Copy link
Contributor

gr2m commented Apr 24, 2019

to acknowledge that I saw your comment.

I tried to reproduce your problem but had no luck so far: https://runkit.com/gr2m/octokit-webhooks-js-75/1.0.0

My best guess is that the problem might be a character in the Russian commit message, but that seems to be fine.

Can you further reduce your code? Maybe use this for your push handler and make sure you don’t register any other handler.

webhooks.on('push', async () => {
  console.log('ok')
})

The next thing we could try is creating a test repository and a tiny app that uses @octokit/webhooks and then try to reproduce the problem there

@gr2m
Copy link
Contributor

gr2m commented May 17, 2019

Any luck @YChebotaev

@YChebotaev
Copy link
Author

@gr2m No, I'm stopped using this library.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Type: Support Any questions, information, or general needs around the SDK or GitHub APIs
Projects
None yet
Development

No branches or pull requests

2 participants