Skip to content

TODO on commit produces a string target ID which breaks Golang serialization

https://github.com/xanzy/go-gitlab/issues/1743

The GitLab TODO API page shows the TODO target.id as an integer. And the most widely-used Golang GitLab client unmarshals that ID to an int. However when a user is mentioned on a commit, the resulting TODO is returned with a target.id of the commit hash which is a string. This breaks unmarshaling.

        "action_name": "mentioned",
        "target_type": "Commit",
        "target": {
            "id": "6a49b920e067e123703578ac38f4819f8e5a2823",
json: cannot unmarshal string into Go struct field TodoTarget.target.id of type int

While there isn't a formal schema (that I'm aware of) the examples clearly show an integer. So GitLab has started producing non-backward compatible TODO JSON output.