Error 500 when commenting a commit

Processing by Projects::NotesController#create as JSON
  Parameters: {"utf8"=>"✓", "authenticity_token"=>"[FILTERED]", "view"=>"inline", "line_type"=>"", "target_type"=>"commit", "target_id"=>"1146830791036f4155d37960a87ca4624677eb8a", "note"=>{"commit_id"=>"1146830791036f4155d37960a87ca4624677eb8a", "line_code"=>"[FILTERED]", "noteable_id"=>"", "noteable_type"=>"Commit"
, "note"=>"some notes"}, "commit"=>"Add Comment", "namespace_id"=>"namespace", "project_id"=>"project"}
Completed 500 Internal Server Error in 920ms (ActiveRecord: 126.1ms)

RangeError (1146830791036 is out of range for ActiveRecord::ConnectionAdapters::PostgreSQL::OID::Integer with limit 4):
  app/services/todo_service.rb:106:in `mark_pending_todos_as_done'
  app/services/todo_service.rb:139:in `handle_note'
  app/services/todo_service.rb:89:in `new_note'
  app/services/notes/create_service.rb:11:in `execute'
  app/controllers/projects/notes_controller.rb:23:in `create'
  lib/gitlab/middleware/readonly_geo.rb:22:in `call'
# == Schema Information
#
# Table name: todos
#
#  id          :integer          not null, primary key
#  user_id     :integer          not null
#  project_id  :integer          not null
#  target_id   :integer          not null
#  target_type :string           not null
#  author_id   :integer
#  note_id     :integer
#  action      :integer          not null
#  state       :string           not null
#  created_at  :datetime
#  updated_at  :datetime
#

The target_id is integer in DB, but the incoming target_id (actually commit_id) is a string.