Skip to content

Fix REST/GRAPHQL APIs handling TODOs WorkItem target

Mario Celi requested to merge 374954-fix-missing-work-item-entity-rest-api into master

What does this MR do and why?

Fixes a bug when a target_type of a TODO is WorkItem instead of Issue. This affected both APIs

How to set up and validate locally

  1. Create a TODO for the logged in user by mentioning the user in an Issue note, leave it as pending
  2. In the console find that todo and change the target_type to WorkItem (todo.update!(target_type: 'WorkItem'))
  3. curl --header "PRIVATE-TOKEN: <your_access_token>" "https://gitlab.example.com/api/v4/todos"
  4. You should get an error before this change (uninitialized constant API::Entities::WorkItem)
  5. In GraphiQL make a query like:
{
  currentUser {
    todos {
      nodes {
        id
	targetType
      }
    }
  }
}

It should also fail before this change

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 #374954 (closed)

Edited by Mario Celi

Merge request reports