xanzy / go-gitlab

GitLab Go SDK
Apache License 2.0
2.36k stars 935 forks source link

cannot unmarshal number into Go struct field .object_attributes.updated_by_id of type string #1904

Closed X-Guardian closed 4 months ago

X-Guardian commented 5 months ago

GitLab have just enabled triggering webhooks when a comment is edited, see: https://gitlab.com/gitlab-org/gitlab/-/merge_requests/127169. This is creating an event that causes this error when trying to unmarshal the event into the gitlab.MergeCommentEvent structure.

It looks like the string type here is incorrect and should be int: https://github.com/xanzy/go-gitlab/blob/f7ec87bca21a42faba6376d20992098500e7988c/event_webhook_types.go#L515

Sample event snippet

{
  "object_kind": "note",
  "event_type": "note",
  ...
  "object_attributes": {
    "attachment": null,
    "author_id": 11901354,
    "change_position": null,
    "commit_id": null,
    "created_at": "2024-02-01 16:56:42 UTC",
    "discussion_id": "b7b737e33d5b87c5f0cf964a231348d2c065b8a8",
    "id": 1754071451,
    "line_code": null,
    "note": "note",
    "noteable_id": 274443493,
    "noteable_type": "MergeRequest",
    "original_position": null,
    "position": null,
    "project_id": 53689091,
    "resolved_at": null,
    "resolved_by_id": null,
    "resolved_by_push": null,
    "st_diff": null,
    "system": false,
    "type": null,
    "updated_at": "2024-03-26 12:15:43 UTC",
    "updated_by_id": 14370654,
    "description": "note",
    "url": "redacted"
  },
  ...
}