Last modified: 2013-11-22 19:30:39 UTC

Wikimedia Bugzilla is closed!

Wikimedia migrated from Bugzilla to Phabricator. Bug reports are handled in Wikimedia Phabricator.
This static website is read-only and for historical purposes. It is not possible to log in and except for displaying bug reports and their history, links might be broken. See T38487, the corresponding Phabricator task for complete and up-to-date bug report information.
Bug 36487 - Gerrit hooks need to accept unicode input
Gerrit hooks need to accept unicode input
Status: RESOLVED INVALID
Product: Wikimedia
Classification: Unclassified
Git/Gerrit (Other open bugs)
unspecified
All All
: Normal normal (vote)
: ---
Assigned To: Nobody - You can work on this!
https://gerrit.wikimedia.org/r/gitweb...
: utf8
Depends on:
Blocks:
  Show dependency treegraph
 
Reported: 2012-05-03 17:19 UTC by Chad H.
Modified: 2013-11-22 19:30 UTC (History)
4 users (show)

See Also:
Web browser: ---
Mobile Platform: ---
Assignee Huggle Beta Tester: ---


Attachments

Description Chad H. 2012-05-03 17:19:43 UTC
Related to bug 35626. Since we've fixed that, I'm getting the following in gerrit's error log:

[2012-05-03 17:11:49,971] INFO  com.google.gerrit.common.ChangeHookRunner : hook[patchset-created] output: Traceback (most recent call last):
[2012-05-03 17:11:49,971] INFO  com.google.gerrit.common.ChangeHookRunner : hook[patchset-created] output:   File "/var/lib/gerrit2/review_site/hooks/patchset-created", line 99, in <module>
[2012-05-03 17:11:49,971] INFO  com.google.gerrit.common.ChangeHookRunner : hook[patchset-created] output:     main()
[2012-05-03 17:11:49,971] INFO  com.google.gerrit.common.ChangeHookRunner : hook[patchset-created] output:   File "/var/lib/gerrit2/review_site/hooks/patchset-created", line 31, in main
[2012-05-03 17:11:49,971] INFO  com.google.gerrit.common.ChangeHookRunner : hook[patchset-created] output:     subject = helper.get_subject(options.change)
[2012-05-03 17:11:49,971] INFO  com.google.gerrit.common.ChangeHookRunner : hook[patchset-created] output:   File "/var/lib/gerrit2/review_site/hooks/hookhelper.py", line 55, in get_subject
[2012-05-03 17:11:49,971] INFO  com.google.gerrit.common.ChangeHookRunner : hook[patchset-created] output:     subject = str(self.patchsets[change]['subject'])
[2012-05-03 17:11:49,972] INFO  com.google.gerrit.common.ChangeHookRunner : hook[patchset-created] output: UnicodeEncodeError: 'ascii' codec can't encode character u'\u2014' in position 24: ordinal not in range(128)
[2012-05-03 17:13:17,210] INFO  com.google.gerrit.common.ChangeHookRunner : hook[change-merged] output: Traceback (most recent call last):
[2012-05-03 17:13:17,211] INFO  com.google.gerrit.common.ChangeHookRunner : hook[change-merged] output:   File "/var/lib/gerrit2/review_site/hooks/change-merged", line 25, in <module>
[2012-05-03 17:13:17,211] INFO  com.google.gerrit.common.ChangeHookRunner : hook[change-merged] output:     main()
[2012-05-03 17:13:17,211] INFO  com.google.gerrit.common.ChangeHookRunner : hook[change-merged] output:   File "/var/lib/gerrit2/review_site/hooks/change-merged", line 22, in main
[2012-05-03 17:13:17,211] INFO  com.google.gerrit.common.ChangeHookRunner : hook[change-merged] output:     helper.update_rt(options.change, options.changeurl)
[2012-05-03 17:13:17,211] INFO  com.google.gerrit.common.ChangeHookRunner : hook[change-merged] output:   File "/var/lib/gerrit2/review_site/hooks/hookhelper.py", line 137, in update_rt
[2012-05-03 17:13:17,211] INFO  com.google.gerrit.common.ChangeHookRunner : hook[change-merged] output:     messages.append(self.get_subject(change))
[2012-05-03 17:13:17,211] INFO  com.google.gerrit.common.ChangeHookRunner : hook[change-merged] output:   File "/var/lib/gerrit2/review_site/hooks/hookhelper.py", line 55, in get_subject
[2012-05-03 17:13:17,211] INFO  com.google.gerrit.common.ChangeHookRunner : hook[change-merged] output:     subject = str(self.patchsets[change]['subject'])
[2012-05-03 17:13:17,211] INFO  com.google.gerrit.common.ChangeHookRunner : hook[change-merged] output: UnicodeEncodeError: 'ascii' codec can't encode character u'\u2014' in position 24: ordinal not in range(128)
Comment 1 Chad H. 2012-05-04 15:09:51 UTC
Not an upstream bug, these hooks are in operations/puppet.git: /files/gerrit/hooks
Comment 2 Marcin Cieślak 2012-05-06 21:13:24 UTC
Yes, all lines like


subject = str(this.patchsets[change]['subject'])

are incorrect - str() tries to convert string (in this case

<type 'unicode'> returned by json (for change 6596):

{u'status': u'MERGED', u'topic': u'master', u'url': u'https://gerrit.wikimedia.org/r/6596', u'createdOn': 1336127682, u'patchSets': [{u'createdOn': 1336127682, u'ref': u'refs/changes/96/6596/1', u'number': u'1', u'uploader': {u'name': u'Szymon \u015awierkosz', u'email': u'beau@adres.pl'}, u'revision': u'6c27fef898ca095e7fd1cc4b6138f1f7e50f3c6f'}, {u'createdOn': 1336127823, u'ref': u'refs/changes/96/6596/2', u'number': u'2', u'uploader': {u'name': u'Szymon \u015awierkosz', u'email': u'beau@adres.pl'}, u'revision': u'caa999a9f1b3653dc3d4556abbb1dfc98ebfab5f'}, {u'createdOn': 1336313263, u'ref': u'refs/changes/96/6596/3', u'number': u'3', u'uploader': {u'name': u'Szymon \u015awierkosz', u'email': u'beau@adres.pl'}, u'revision': u'7cf5f38232111da6ec8834764628aa29422382c1'}], u'number': u'6596', u'lastUpdated': 1336313647, u'project': u'mediawiki/core', u'sortKey': u'001cdcf6000019c4', u'branch': u'master', u'owner': {u'name': u'Szymon \u015awierkosz', u'email': u'beau@adres.pl'}, u'open': False, u'id': u'Ie223930cfc313aff150e2dcfd70b74bf4360a8a8', u'subject': u'Move optionstoken from meta=userinfo to action=tokens.'}

and then we should consequently treat all strings as Unicode and converting to UTF-8 when logging to files or doing other I/O.

I wonder only, why did it work before?
Comment 3 Chad H. 2013-11-22 19:30:39 UTC
Not a bug anymore since we got rid of these hooks.

Note You need to log in before you can comment on or make changes to this bug.


Navigation
Links