[go: up one dir, main page]

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

Created by: X-Guardian

GitLab have just enabled triggering webhooks when a comment is edited, see: gitlab-org/gitlab!127169 (merged). 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"
  },
  ...
}