Commit hashes that begin with 10 or more digits break notes-functionality within project
Created by: hmehta
Commit hashes that being with 10 or more digits break leaving notes within the project when the commit hash is mentioned in the note. The comment doesn't post and the following error message will appear in production.log:
Started POST "/hmehta/rebase-test/notes" for 127.0.0.1 at 2014-02-05 15:41:27 +0000
Processing by Projects::NotesController#create as JSON
Parameters: {"utf8"=>"✓", "authenticity_token"=>"YNjs+OZOp9svrqUdtOryiWw3QUmYIAup9VoTuuGepcY=", "target_type"=>"", "target_id"=>"", "note"=>{"commit_id"=>""
, "noteable_id"=>"309", "noteable_type"=>"MergeRequest", "note"=>"71993536"}, "commit"=>"Add Comment", "project_id"=>"hmehta/rebase-test"}
Mysql2::Error: Out of range value for column 'noteable_id' at row 1: INSERT INTO `notes` (`author_id`, `commit_id`, `created_at`, `note`, `noteable_id`, `note
able_type`, `project_id`, `st_diff`, `system`, `updated_at`) VALUES (2, '71993536071971f1a5988adb4b0cd20c3750a5d6', '2014-02-05 15:41:27', '_mentioned in merg
e request !2_', 71993536071971, 'Commit', 160, NULL, 1, '2014-02-05 15:41:27')
Completed 500 Internal Server Error in 132ms
ActiveRecord::StatementInvalid (Mysql2::Error: Out of range value for column 'noteable_id' at row 1: INSERT INTO `notes` (`author_id`, `commit_id`, `created_a
t`, `note`, `noteable_id`, `noteable_type`, `project_id`, `st_diff`, `system`, `updated_at`) VALUES (2, '71993536071971f1a5988adb4b0cd20c3750a5d6', '2014-02-0
5 15:41:27', '_mentioned in merge request !2_', 71993536071971, 'Commit', 160, NULL, 1, '2014-02-05 15:41:27')):
app/models/note.rb:82:in `create_cross_reference_note'
app/observers/note_observer.rb:9:in `block in after_create'
app/observers/note_observer.rb:8:in `each'
app/observers/note_observer.rb:8:in `after_create'
app/services/notes/create_service.rb:6:in `execute'
app/controllers/projects/notes_controller.rb:23:in `create'
app/controllers/application_controller.rb:57:in `set_current_user_for_thread'
EDIT: rewrote most of the stuff to make the issue look more sane :)