mirage / ocaml-github

GitHub APIv3 OCaml bindings
ISC License
100 stars 61 forks source link

handle "Bot" user type #270

Closed zoggy closed 6 months ago

zoggy commented 7 months ago

Handle Bot user type, which prevents the parser failing when it encounters it.

tmcgilchrist commented 7 months ago

Thanks for the contribution @zoggy

Do you have an example response that shows this bot type response? Or a link to the GitHub docs detailing the values of user_type?

Also could you add a changelog entry for this fix.

zoggy commented 7 months ago

The following command will return events on issue 11807, with an action from the github-actions bot, whose type is "Bot":

$ curl  -H "Accept: application/vnd.github+json"   https://api.github.com/repos/ocaml/ocaml/issues/11807/events
[...]
{
    "id": 11255263906,
    "node_id": "LE_lADOAGeMds5Y07DgzwAAAAKe3bKi",
    "url": "https://api.github.com/repos/ocaml/ocaml/issues/events/11255263906",
    "actor": {
      "login": "github-actions[bot]",
      "id": 41898282,
      "node_id": "MDM6Qm90NDE4OTgyODI=",
      "avatar_url": "https://avatars.githubusercontent.com/in/15368?v=4",
      "gravatar_id": "",
      "url": "https://api.github.com/users/github-actions%5Bbot%5D",
      "html_url": "https://github.com/apps/github-actions",
      "followers_url": "https://api.github.com/users/github-actions%5Bbot%5D/followers",
      "following_url": "https://api.github.com/users/github-actions%5Bbot%5D/following{/other_user}",
      "gists_url": "https://api.github.com/users/github-actions%5Bbot%5D/gists{/gist_id}",
      "starred_url": "https://api.github.com/users/github-actions%5Bbot%5D/starred{/owner}{/repo}",
      "subscriptions_url": "https://api.github.com/users/github-actions%5Bbot%5D/subscriptions",
      "organizations_url": "https://api.github.com/users/github-actions%5Bbot%5D/orgs",
      "repos_url": "https://api.github.com/users/github-actions%5Bbot%5D/repos",
      "events_url": "https://api.github.com/users/github-actions%5Bbot%5D/events{/privacy}",
      "received_events_url": "https://api.github.com/users/github-actions%5Bbot%5D/received_events",
      "type": "Bot",
      "site_admin": false
    },
    "event": "labeled",
    "commit_id": null,
    "commit_url": null,
    "created_at": "2023-12-15T04:23:35Z",
    "label": {
      "name": "Stale",
      "color": "ededed"
    },
    "performed_via_github_app": null
  },
[...]

I can't find documentation on possible user types in github rest API doc.