xanzy / go-gitlab

GitLab Go SDK

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

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

X-Guardian opened this issue · comments

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:

UpdatedByID string `json:"updated_by_id"`

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"
  },
  ...
}