Skip to content

ArgumentError in Todos API

Summary

https://sentry.gitlab.net/gitlab/gitlabcom/issues/1679085/?referrer=gitlab_plugin

ArgumentError: Unsupported todo type passed. Supported todo types are: Issue, MergeRequest, DesignManagement::Design, Epic
(137 additional frame(s) were not displayed)
...
  api/todos.rb:78:in `block (2 levels) in <class:Todos>'
    todos = paginate(find_todos.with_entity_associations)
  api/todos.rb:43:in `find_todos'
    TodosFinder.new(current_user, params).execute
  finder_with_cross_project_access.rb:40:in `execute'
    return original.call if should_skip_cross_project_check || can_read_cross_project?
  finder_with_cross_project_access.rb:37:in `block in execute'
    original = -> { super }
  todos_finder.rb:43:in `execute'
    raise ArgumentError, invalid_type_message unless valid_types?

ArgumentError: Unsupported todo type passed. Supported todo types are: Issue, MergeRequest, DesignManagement::Design, Epic

Proposal

Catch invalid todo types in the API layer, and return an appropriate response.

We could also consider ignoring case in this parameter, in the Sentry example above the client was sending issue when it should be Issue.

Edited by Markus Koller