Skip to content

Comment with unicode emoji result in 500 Internal Server Error

Created by: Senorsen

When using unicode emoji (👍) in Android or iOS phone (which can input unicode emoji characters) , there's a 500 Internal Server Error and the ajax refresh fails.

I'm using GitLab 7.9.0.rc3 68dcfab which uses MySQL.

part of production.log:

Started POST "/qsc-mobile/qsc-mobile-ios/notes" for 127.0.0.1 at 2015-03-26 08:07:12 +0800
Processing by Projects::NotesController#create as JSON
  Parameters: {"utf8"=>"✓", "authenticity_token"=>"hidden", "target_type"=>"commit", "target_id"=>"hidden", "note"=>{"commit_id"=>"hidden", "noteable_id"=>"", "noteable_type"=>"Commit", "note"=>"👍"}, "commit"=>"Add Comment", "namespace_id"=>"qsc-mobile", "project_id"=>"qsc-mobile-ios"}
Mysql2::Error: Incorrect string value: '\xF0\x9F\x91\x8D' for column 'note' at row 1: INSERT INTO `notes` (`author_id`, `commit_id`, `created_at`, `note`, `noteable_type`, `project_id`, `st_diff`, `system`, `updated_at`) VALUES (21, 'hidden', '2015-03-26 00:07:12', '👍', 'Commit', 2, NULL, 0, '2015-03-26 00:07:12')

Sent mail to xxxx@gmail.com (1582.0ms)
Completed 500 Internal Server Error in 113ms

ActiveRecord::StatementInvalid (Mysql2::Error: Incorrect string value: '\xF0\x9F\x91\x8D' for column 'note' at row 1: INSERT INTO `notes` (`author_id`, `commit_id`, `created_at`, `note`, `noteable_type`, `project_id`, `st_diff`, `system`, `updated_at`) VALUES (21, 'hidden', '2015-03-26 00:07:12', '👍', 'Commit', 2, NULL, 0, '2015-03-26 00:07:12')):
  app/services/notes/create_service.rb:8:in `execute'
  app/controllers/projects/notes_controller.rb:24:in `create'
  lib/gitlab/middleware/timeout.rb:9:in `call'



Sent mail to yyyy@gmail.com (1623.4ms)

Sent mail to xxxx@me.com (1698.1ms)

Thanks.