Skip to content

Fix todo API when used with Alerts

Sean Arnold requested to merge 345009-fix-todos-for-alerts into master

What does this MR do and why?

Describe in detail what your merge request does and why.

This fixes a bug where currently the TODOs API returns a 500 if an AlertManagement::Alert todo is present.

Request:
curl --location --request GET 'http://gdk.test:3000/api/v4/todos' \
--header 'PRIVATE-TOKEN: token' \
Response:
[
    {
        "id": 8,
        "project": {
            "id": 6,
            "description": "Provident doloremque blanditiis enim aut.",
            "name": "Flight",
            "name_with_namespace": "Flightjs / Flight",
            "path": "Flight",
            "path_with_namespace": "flightjs/Flight",
            "created_at": "2021-09-27T20:58:16.048Z"
        },
        "author": {
            "id": 1,
            "name": "Administrator",
            "username": "root",
            "state": "active",
            "avatar_url": "https://www.gravatar.com/avatar/e64c7d89f26bd1972efa854d13d7dd61?s=80&d=identicon",
            "web_url": "http://gdk.test:3000/root"
        },
        "action_name": "assigned",
        "target_type": "AlertManagement::Alert",
        "target": {
            "iid": 1,
            "title": "Memory usage exceeded threshold"
        },
        "target_url": "http://gdk.test:3000/flightjs/Flight/-/alert_management/1",
        "body": "Memory usage exceeded threshold",
        "state": "pending",
        "created_at": "2021-11-07T22:55:18.857Z",
        "updated_at": "2021-11-07T22:55:18.857Z"
    }
]

Screenshots or screen recordings

These are strongly recommended to assist reviewers and reduce the time to merge your change.

How to set up and validate locally

Numbered steps to set up and validate the change are strongly suggested.

MR acceptance checklist

This checklist encourages us to confirm any changes have been analyzed to reduce risks in quality, performance, reliability, security, and maintainability.

Related to #345009 (closed)

Edited by Sean Arnold

Merge request reports