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

commit_comment.created events are not deserialized properly in webhook events #452

Closed
gagbo opened this issue Sep 1, 2023 · 0 comments
Closed
Labels
bug Something isn't working good first issue Good for newcomers help wanted Extra attention is needed

Comments

@gagbo
Copy link
Contributor

gagbo commented Sep 1, 2023

Similar to other deserialization errors, I found a new payload that doesn't work with current webhook events.

Payload

Header : X-GitHub-Event is commit_comment

{
    "action": "created",
    "comment": {
        "url": "https://api.github.com/repos/gagbo/app-test-repo/comments/126171404",
        "html_url": "https://github.com/gagbo/app-test-repo/commit/5a722779076a943e9e8ccc502566c411f6481b4a#commitcomment-126171404",
        "id": 126171404,
        "node_id": "CC_kwDOKIoqtM4HhTkM",
        "user": {
            "login": "gagbo",
            "id": 10496163,
            "node_id": "MDQ6VXNlcjEwNDk2MTYz",
            "avatar_url": "https://avatars.githubusercontent.com/u/10496163?v=4",
            "gravatar_id": "",
            "url": "https://api.github.com/users/gagbo",
            "html_url": "https://github.com/gagbo",
            "followers_url": "https://api.github.com/users/gagbo/followers",
            "following_url": "https://api.github.com/users/gagbo/following{/other_user}",
            "gists_url": "https://api.github.com/users/gagbo/gists{/gist_id}",
            "starred_url": "https://api.github.com/users/gagbo/starred{/owner}{/repo}",
            "subscriptions_url": "https://api.github.com/users/gagbo/subscriptions",
            "organizations_url": "https://api.github.com/users/gagbo/orgs",
            "repos_url": "https://api.github.com/users/gagbo/repos",
            "events_url": "https://api.github.com/users/gagbo/events{/privacy}",
            "received_events_url": "https://api.github.com/users/gagbo/received_events",
            "type": "User",
            "site_admin": false
        },
        "position": null,
        "line": null,
        "path": null,
        "commit_id": "5a722779076a943e9e8ccc502566c411f6481b4a",
        "created_at": "2023-09-01T12:01:16Z",
        "updated_at": "2023-09-01T12:01:16Z",
        "author_association": "OWNER",
        "body": "@gagbo-test-app[bot] compare-tag v0.1",
        "reactions": {
            "url": "https://api.github.com/repos/gagbo/app-test-repo/comments/126171404/reactions",
            "total_count": 0,
            "+1": 0,
            "-1": 0,
            "laugh": 0,
            "hooray": 0,
            "confused": 0,
            "heart": 0,
            "rocket": 0,
            "eyes": 0
        }
    },
    "repository": {
        "id": 680143540,
        "node_id": "R_kgDOKIoqtA",
        "name": "app-test-repo",
        "full_name": "gagbo/app-test-repo",
        "private": false,
        "owner": {
            "login": "gagbo",
            "id": 10496163,
            "node_id": "MDQ6VXNlcjEwNDk2MTYz",
            "avatar_url": "https://avatars.githubusercontent.com/u/10496163?v=4",
            "gravatar_id": "",
            "url": "https://api.github.com/users/gagbo",
            "html_url": "https://github.com/gagbo",
            "followers_url": "https://api.github.com/users/gagbo/followers",
            "following_url": "https://api.github.com/users/gagbo/following{/other_user}",
            "gists_url": "https://api.github.com/users/gagbo/gists{/gist_id}",
            "starred_url": "https://api.github.com/users/gagbo/starred{/owner}{/repo}",
            "subscriptions_url": "https://api.github.com/users/gagbo/subscriptions",
            "organizations_url": "https://api.github.com/users/gagbo/orgs",
            "repos_url": "https://api.github.com/users/gagbo/repos",
            "events_url": "https://api.github.com/users/gagbo/events{/privacy}",
            "received_events_url": "https://api.github.com/users/gagbo/received_events",
            "type": "User",
            "site_admin": false
        },
        "html_url": "https://github.com/gagbo/app-test-repo",
        "description": "Nothing to see here, just testing Github App hooks",
        "fork": false,
        "url": "https://api.github.com/repos/gagbo/app-test-repo",
        "forks_url": "https://api.github.com/repos/gagbo/app-test-repo/forks",
        "keys_url": "https://api.github.com/repos/gagbo/app-test-repo/keys{/key_id}",
        "collaborators_url": "https://api.github.com/repos/gagbo/app-test-repo/collaborators{/collaborator}",
        "teams_url": "https://api.github.com/repos/gagbo/app-test-repo/teams",
        "hooks_url": "https://api.github.com/repos/gagbo/app-test-repo/hooks",
        "issue_events_url": "https://api.github.com/repos/gagbo/app-test-repo/issues/events{/number}",
        "events_url": "https://api.github.com/repos/gagbo/app-test-repo/events",
        "assignees_url": "https://api.github.com/repos/gagbo/app-test-repo/assignees{/user}",
        "branches_url": "https://api.github.com/repos/gagbo/app-test-repo/branches{/branch}",
        "tags_url": "https://api.github.com/repos/gagbo/app-test-repo/tags",
        "blobs_url": "https://api.github.com/repos/gagbo/app-test-repo/git/blobs{/sha}",
        "git_tags_url": "https://api.github.com/repos/gagbo/app-test-repo/git/tags{/sha}",
        "git_refs_url": "https://api.github.com/repos/gagbo/app-test-repo/git/refs{/sha}",
        "trees_url": "https://api.github.com/repos/gagbo/app-test-repo/git/trees{/sha}",
        "statuses_url": "https://api.github.com/repos/gagbo/app-test-repo/statuses/{sha}",
        "languages_url": "https://api.github.com/repos/gagbo/app-test-repo/languages",
        "stargazers_url": "https://api.github.com/repos/gagbo/app-test-repo/stargazers",
        "contributors_url": "https://api.github.com/repos/gagbo/app-test-repo/contributors",
        "subscribers_url": "https://api.github.com/repos/gagbo/app-test-repo/subscribers",
        "subscription_url": "https://api.github.com/repos/gagbo/app-test-repo/subscription",
        "commits_url": "https://api.github.com/repos/gagbo/app-test-repo/commits{/sha}",
        "git_commits_url": "https://api.github.com/repos/gagbo/app-test-repo/git/commits{/sha}",
        "comments_url": "https://api.github.com/repos/gagbo/app-test-repo/comments{/number}",
        "issue_comment_url": "https://api.github.com/repos/gagbo/app-test-repo/issues/comments{/number}",
        "contents_url": "https://api.github.com/repos/gagbo/app-test-repo/contents/{+path}",
        "compare_url": "https://api.github.com/repos/gagbo/app-test-repo/compare/{base}...{head}",
        "merges_url": "https://api.github.com/repos/gagbo/app-test-repo/merges",
        "archive_url": "https://api.github.com/repos/gagbo/app-test-repo/{archive_format}{/ref}",
        "downloads_url": "https://api.github.com/repos/gagbo/app-test-repo/downloads",
        "issues_url": "https://api.github.com/repos/gagbo/app-test-repo/issues{/number}",
        "pulls_url": "https://api.github.com/repos/gagbo/app-test-repo/pulls{/number}",
        "milestones_url": "https://api.github.com/repos/gagbo/app-test-repo/milestones{/number}",
        "notifications_url": "https://api.github.com/repos/gagbo/app-test-repo/notifications{?since,all,participating}",
        "labels_url": "https://api.github.com/repos/gagbo/app-test-repo/labels{/name}",
        "releases_url": "https://api.github.com/repos/gagbo/app-test-repo/releases{/id}",
        "deployments_url": "https://api.github.com/repos/gagbo/app-test-repo/deployments",
        "created_at": "2023-08-18T12:53:34Z",
        "updated_at": "2023-08-18T16:51:35Z",
        "pushed_at": "2023-09-01T10:42:50Z",
        "git_url": "git://github.com/gagbo/app-test-repo.git",
        "ssh_url": "[email protected]:gagbo/app-test-repo.git",
        "clone_url": "https://github.com/gagbo/app-test-repo.git",
        "svn_url": "https://github.com/gagbo/app-test-repo",
        "homepage": null,
        "size": 13,
        "stargazers_count": 1,
        "watchers_count": 1,
        "language": "Rust",
        "has_issues": true,
        "has_projects": true,
        "has_downloads": true,
        "has_wiki": true,
        "has_pages": false,
        "has_discussions": false,
        "forks_count": 0,
        "mirror_url": null,
        "archived": false,
        "disabled": false,
        "open_issues_count": 0,
        "license": null,
        "allow_forking": true,
        "is_template": false,
        "web_commit_signoff_required": false,
        "topics": [],
        "visibility": "public",
        "forks": 0,
        "open_issues": 0,
        "watchers": 1,
        "default_branch": "main"
    },
    "sender": {
        "login": "gagbo",
        "id": 10496163,
        "node_id": "MDQ6VXNlcjEwNDk2MTYz",
        "avatar_url": "https://avatars.githubusercontent.com/u/10496163?v=4",
        "gravatar_id": "",
        "url": "https://api.github.com/users/gagbo",
        "html_url": "https://github.com/gagbo",
        "followers_url": "https://api.github.com/users/gagbo/followers",
        "following_url": "https://api.github.com/users/gagbo/following{/other_user}",
        "gists_url": "https://api.github.com/users/gagbo/gists{/gist_id}",
        "starred_url": "https://api.github.com/users/gagbo/starred{/owner}{/repo}",
        "subscriptions_url": "https://api.github.com/users/gagbo/subscriptions",
        "organizations_url": "https://api.github.com/users/gagbo/orgs",
        "repos_url": "https://api.github.com/users/gagbo/repos",
        "events_url": "https://api.github.com/users/gagbo/events{/privacy}",
        "received_events_url": "https://api.github.com/users/gagbo/received_events",
        "type": "User",
        "site_admin": false
    },
    "installation": {
        "id": 88888888,
        "node_id": "MDIzOkludGVncmF0aW9uSW5zdGFsbGF0aW9uMzk1OTM1MjA="
    }
}

Error

serialization/deserialization error: unknown variant `total_count`, expected one of `heart`, `+1`, `laugh`, `confused`, `hooray`, `-1`, `rocket`, `eyes`
@XAMPPRocky XAMPPRocky added bug Something isn't working help wanted Extra attention is needed good first issue Good for newcomers labels Sep 1, 2023
gagbo added a commit to gagbo/octocrab that referenced this issue Sep 1, 2023
The list of reactions in commit_comment events was badly represented.
The correct type has directly been added in the models::commits::Comment
struct, so everything has the better typing out of the box.

This also enforces strong typing with the author_association field.

Fixes XAMPPRocky#452
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working good first issue Good for newcomers help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

2 participants