Commit hashes that begin with 10 or more digits break notes-functionality within project
I challenge you to post a comment which includes the failing hashes this bug can be reproduced on gitlab.com
This issue has been ported from github gitlabhq issue 6251.
Commit hashes that being with 10 or more digits break leaving notes within the project when the commit hash is mentioned in the note. To clarify, the hash must start with 10 or more digits. I have reproduced this issue. It can also be noted that the number of leading digits can be extended if the hash starts with zeros (but still limited to 9 digits).
Hashes leading with 9 digits
I'll use the gitlabhq repository as an example. Referencing the following hashes work.
798360194a94f2df787ef59e669f17793af92f4b
380342784d3efbecb98de81c9b2679e3d720f7c9
904745560aa8665f9076374b2c436329c8d658d3
Hashes leading with 10 or more digits
However referencing hashes which lead with more than 9 digits (e.g. 10) result in the internal server error consistently. Note: remove space when testing hashes in the comments section. I had to put a space in the hashes because filing or updating this issue ended with 500 internal server error.
92 47490109b9d4e4691d304e7bfb4bca6d54e209
87 81459124b87912b105bab3c2b67c46f5457db9
46 50855685ec57fabdb66e0004f08b59b07706cc
Hashes with leading zeros but less than 10 non-zero digits following
Hashes with leading zeros but less than 10 non-zero digits following do work. Here are two hashes which work.
0542261437fd9df7539fe480069449b566057300
0675552463c5afccd81bbfe1ff276d19d0d79446
0103363191d63d9a81bfeba61abf443532f47183
Leading with 2 zeros and 9 following digits also works.
00464099704ec16ad64faa3fe8c19d931ee7037a
Production.log
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`, `noteable_type`, `project_id`, `st_diff`, `system`, `updated_at`) VALUES (30, '92 47490109b9d4e4691d304e7bfb4bca6d54e209', '2014-02-05 16:13:41', '_mentioned in issue #1_', 92 47490109, 'Commit', 147, NULL, 1, '2014-02-05 16:13:41')
Completed 500 Internal Server Error in 105ms
ActiveRecord::StatementInvalid (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`, `noteable_type`, `project_id`, `st_diff`, `system`, `updated_at`) VALUES (30, '92 47490109b9d4e4691d304e7bfb4bca6d54e209', '2014-02-05 16:13:41', '_mentioned in issue #1_', 92 47490109, 'Commit', 147, NULL, 1, '2014-02-05 16:13:41')):
app/models/note.rb:74: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/contexts/notes/create_context.rb:6:in `execute'
app/controllers/projects/notes_controller.rb:28:in `create'
app/controllers/application_controller.rb:57:in `set_current_user_for_thread'
MySQL database query showing the problem.
Excerpt modified to point out field.
mysql> DESCRIBE notes;
+---------------+--------------+------+-----+---------+----------------+
| Field | Type | Null | Key | Default | Extra |
+---------------+--------------+------+-----+---------+----------------+
| noteable_id | int(11) | YES | MUL | NULL | |
+---------------+--------------+------+-----+---------+----------------+
13 rows in set (0.00 sec)