Bug 12374

Summary: Error on git push while generating commit email
Product: Infrastructure Reporter: Rémi Verschelde <rverschelde>
Component: OthersAssignee: Sysadmin Team <sysadmin-bugs>
Status: RESOLVED FIXED QA Contact:
Severity: normal    
Priority: Normal CC: mageia, sysadmin-bugs, tmb
Version: unspecified   
Target Milestone: ---   
Hardware: x86_64   
OS: Linux   
URL: ssh://git@git.mageia.org/
Whiteboard:
Source RPM: CVE:
Status comment:

Description Rémi Verschelde 2014-01-21 09:06:41 CET
I hit the same error each time I push something to git, namely that it can't generate the email to send to soft-commits@ml.mageia.org.

See the error log below on an example:

--

[akien@cauldron mageia-gfxboot-theme (master)]$ git commit -m "Fix references to YaST2 and use DrakX instead (mga#1823)"
[master 44c19e7] Fix references to YaST2 and use DrakX instead (mga#1823)
 78 files changed, 78 insertions(+), 78 deletions(-)

[akien@cauldron mageia-gfxboot-theme (master)]$ git push
X11 forwarding request failed on channel 0
Counting objects: 167, done.
Delta compression using up to 4 threads.
Compressing objects: 100% (119/119), done.
Writing objects: 100% (119/119), 25.95 KiB | 0 bytes/s, done.
Total 119 (delta 71), reused 0 (delta 0)
remote: Sending notification emails to: soft-commits@ml.mageia.org
remote: *** Error while generating commit email
remote: ***  - mail sending aborted.
remote: Traceback (most recent call last):
remote:   File "hooks/post-receive", line 185, in <module>
remote:     git_multimail.main(sys.argv[1:])
remote:   File "/var/lib/git/.gitolite/hooks/common/git_multimail.py", line 2451, in main
remote:     run_as_post_receive_hook(environment, mailer)
remote:   File "/var/lib/git/.gitolite/hooks/common/git_multimail.py", line 2303, in run_as_post_receive_hook
remote:     push.send_emails(mailer, body_filter=environment.filter_body)
remote:   File "/var/lib/git/.gitolite/hooks/common/git_multimail.py", line 2284, in send_emails
remote:     mailer.send(rev.generate_email(self, body_filter), rev.recipients)
remote:   File "/var/lib/git/.gitolite/hooks/common/git_multimail.py", line 1375, in send
remote:     p.stdin.writelines(lines)
remote:   File "/var/lib/git/.gitolite/hooks/common/git_multimail.py", line 683, in generate_email
remote:     for line in self.generate_email_header():
remote:   File "/var/lib/git/.gitolite/hooks/common/git_multimail.py", line 740, in generate_email_header
remote:     for line in self.expand_header_lines(REVISION_HEADER_TEMPLATE):
remote:   File "/var/lib/git/.gitolite/hooks/common/git_multimail.py", line 638, in expand_header_lines
remote:     value = addr_header_encode(value, name)
remote:   File "/var/lib/git/.gitolite/hooks/common/git_multimail.py", line 352, in addr_header_encode
remote:     header_name=header_name
remote:   File "/usr/lib64/python2.7/email/header.py", line 179, in __init__
remote:     self.append(s, charset, errors)
remote:   File "/usr/lib64/python2.7/email/header.py", line 263, in append
remote:     ustr = unicode(s, incodec, errors)
remote: UnicodeDecodeError: 'ascii' codec can't decode byte 0xc3 in position 1: ordinal not in range(128)
To ssh://git@git.mageia.org/software/design/bootloader-theme
   5a0171b..44c19e7  master -> master


Reproducible: 

Steps to Reproduce:
Comment 1 Rémi Verschelde 2014-03-05 09:22:10 CET
Still valid on Cauldron.
Comment 2 Rémi Verschelde 2014-04-26 09:34:40 CEST
I still get it on Cauldron:

[akien@cauldron desktop-common-data (master)]$ git push
X11 forwarding request failed on channel 0
Counting objects: 29, done.
Delta compression using up to 4 threads.
Compressing objects: 100% (18/18), done.
Writing objects: 100% (18/18), 2.70 KiB | 0 bytes/s, done.
Total 18 (delta 10), reused 0 (delta 0)
remote: Sending notification emails to: soft-commits@ml.mageia.org
remote: *** Error while generating commit email
remote: ***  - mail sending aborted.
remote: Traceback (most recent call last):
remote:   File "hooks/post-receive", line 277, in <module>
remote:     push.send_emails(mailer, body_filter=environment.filter_body)
remote:   File "/var/lib/git/.gitolite/hooks/common/git_multimail.py", line 2278, in send_emails
remote:     mailer.send(rev.generate_email(self, body_filter), rev.recipients)
remote:   File "/var/lib/git/.gitolite/hooks/common/git_multimail.py", line 1375, in send
remote:     p.stdin.writelines(lines)
remote:   File "/var/lib/git/.gitolite/hooks/common/git_multimail.py", line 683, in generate_email
remote:     for line in self.generate_email_header():
remote:   File "/var/lib/git/.gitolite/hooks/common/git_multimail.py", line 740, in generate_email_header
remote:     for line in self.expand_header_lines(REVISION_HEADER_TEMPLATE):
remote:   File "/var/lib/git/.gitolite/hooks/common/git_multimail.py", line 638, in expand_header_lines
remote:     value = addr_header_encode(value, name)
remote:   File "/var/lib/git/.gitolite/hooks/common/git_multimail.py", line 352, in addr_header_encode
remote:     header_name=header_name
remote:   File "/usr/lib64/python2.7/email/header.py", line 179, in __init__
remote:     self.append(s, charset, errors)
remote:   File "/usr/lib64/python2.7/email/header.py", line 263, in append
remote:     ustr = unicode(s, incodec, errors)
remote: UnicodeDecodeError: 'ascii' codec can't decode byte 0xc3 in position 1: ordinal not in range(128)
To ssh://git@git.mageia.org/software/desktop/common-data
   8f825d3..c500b58  master -> master


@Colin: Any clue?

CC: (none) => mageia

Comment 3 Colin Guthrie 2014-04-26 13:55:37 CEST
Oh sorry Rémi, I didn't notice this one earlier :( (or if I did, it slipped of my radar)

I'm going to guess it's the "é" that is to blame. I'll see if I can work it out!
Comment 4 Mageia Robot 2014-04-26 13:57:36 CEST
commit 33a1d3569c351ab54d3664a1e60e3cfdb060d96e
Author: Colin Guthrié <colin@...>
Date:   Sat Apr 26 12:57:08 2014 +0100

    Setting a daté
    
    Testing mga#12374
---
 Commit Link:
   http://gitweb.mageia.org/software/test/commit/?id=33a1d3569c351ab54d3664a1e60e3cfdb060d96e
Comment 5 Colin Guthrie 2014-04-26 13:58:52 CEST
Hmm, perhaps not then....
Comment 6 Colin Guthrie 2014-04-26 14:10:42 CEST
OK, so I did a test commit above.

If I clone the test repo and do a git format-patch and look at the header of the patch file generated, I get:

From 33a1d3569c351ab54d3664a1e60e3cfdb060d96e Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Colin=20Guthri=C3=A9?= <colin@...>
Date: Sat, 26 Apr 2014 12:57:08 +0100
Subject: [PATCH] =?UTF-8?q?Setting=20a=20dat=C3=A9?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit


If I take the commit you're referring to above and do a format-patch on it, I get the following header:

From 44c19e7f189a708f1c777fe64bc519ab0ab8b2c6 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?R=C3=A9mi=20Verschelde?= <remi@...>
Date: Tue, 21 Jan 2014 08:48:21 +0100
Subject: [PATCH] Fix references to YaST2 and use DrakX instead (mga#1823)



Note the lack of the MIME-Version, Content-Type and Content-Transfer-Encoding headers. Not sure this is really to blame, but it's the only difference I can see that is obvious.

Is your system locale (the one where you commit your changes) UTF-8?

[colin@jimmy test (master)]$ echo $LC_COLLATE 
en_GB.UTF-8
Comment 7 Rémi Verschelde 2014-04-26 14:15:49 CEST
My system locale is also UTF-8:

[akien@cauldron ~]$ echo $LC_COLLATE
fr_FR.UTF-8

[akien@cauldron ~]$ locale
LANG=fr_FR.UTF-8
LC_CTYPE=fr_FR.UTF-8
LC_NUMERIC=fr_FR.UTF-8
LC_TIME=fr_FR.UTF-8
LC_COLLATE=fr_FR.UTF-8
LC_MONETARY=fr_FR.UTF-8
LC_MESSAGES=fr_FR.UTF-8
LC_PAPER=fr_FR.UTF-8
LC_NAME=fr_FR.UTF-8
LC_ADDRESS=fr_FR.UTF-8
LC_TELEPHONE=fr_FR.UTF-8
LC_MEASUREMENT=fr_FR.UTF-8
LC_IDENTIFICATION=fr_FR.UTF-8
LC_ALL=
Comment 8 Colin Guthrie 2014-04-26 14:19:26 CEST
Weird. It's definitely choking on the é (C3 A9), but it's odd that it currently *thinks* it's in ascii mode when it should be decoding utf8...

Can you post a trivial change to the test repo please (like mine above) just to make sure it happens there too?

Cheers!
Comment 9 Mageia Robot 2014-04-26 14:28:13 CEST
commit d484071d1cf3bafc9a3efcc2108621bd427ba4de
Author: Remi Verschelde <remi@...>
Date:   Sat Apr 26 14:28:08 2014 +0200

    Testing mga#12374 too
---
 Commit Link:
   http://gitweb.mageia.org/software/test/commit/?id=d484071d1cf3bafc9a3efcc2108621bd427ba4de
Comment 10 Rémi Verschelde 2014-04-26 14:29:57 CEST
I just did a test commit locally on the test repo, and the format-patch still lacks the MIME-Version, Content-Type and Content-Transfer-Encoding, so that might be a clue (especially the "transfer encoding" thing).

I did a test commit to the test repo and could confirm that the issue is linked to the "é" in my name.

The format-patch header is then:

From d484071d1cf3bafc9a3efcc2108621bd427ba4de Mon Sep 17 00:00:00 2001
From: Remi Verschelde <remi@verschelde.fr>
Date: Sat, 26 Apr 2014 14:28:08 +0200
Subject: [PATCH] Testing mga#12374 too
Comment 11 Rémi Verschelde 2014-04-26 14:30:09 CEST
Sure, I'll try again with the "é".
Comment 12 Rémi Verschelde 2014-04-26 14:32:33 CEST
Yes, the issue still happens in the test repo.
Comment 13 Colin Guthrie 2014-04-26 14:37:20 CEST
OK, the transfer encoding thing and those extra headers is due to me putting an accented character in the actual commit message...

With a "normal" commit message i don't get those headers either in my format-patch, so that's a red herring I think.

I just tried again with a simpler push and it worked, but when using *your* name, it failed... I guess the difference is that the é was in the middle, not the end... some more experiments needed I think!
Comment 14 Mageia Robot 2014-04-26 14:38:42 CEST
commit 6fa4636d19c6c1a0e566149f1435e2d5805c3539
Author: Remi Verscheldé <colin@...>
Date:   Sat Apr 26 13:38:39 2014 +0100

    Setting a date 4 mga#12374
---
 Commit Link:
   http://gitweb.mageia.org/software/test/commit/?id=6fa4636d19c6c1a0e566149f1435e2d5805c3539
Comment 15 Mageia Robot 2014-04-26 14:39:23 CEST
commit e7fdd7bc03683756a90cc65d53784996a0f812b9
Author: Remi Verscheldéx <colin@...>
Date:   Sat Apr 26 13:39:20 2014 +0100

    Setting a date 5 mga#12374
---
 Commit Link:
   http://gitweb.mageia.org/software/test/commit/?id=e7fdd7bc03683756a90cc65d53784996a0f812b9
Comment 16 Mageia Robot 2014-04-26 14:39:47 CEST
commit b220123ff4b04ffc8ac15d68b24c743fc1fb0646
Author: Remi Verscheldé Foo <colin@...>
Date:   Sat Apr 26 13:39:44 2014 +0100

    Setting a date 6 mga#12374
---
 Commit Link:
   http://gitweb.mageia.org/software/test/commit/?id=b220123ff4b04ffc8ac15d68b24c743fc1fb0646
Comment 17 Colin Guthrie 2014-04-26 14:40:52 CEST
It seems that it fails when it's in the first word of the name.... i.e. in a surname it's fine, but until it encounters a space, it doesn't work... very odd. Seems like a python bug to me....
Comment 18 Colin Guthrie 2014-04-26 14:41:24 CEST
Gotta run... will try and look more later!
Comment 19 Colin Guthrie 2014-04-27 15:55:26 CEST
OK, so tested local (mga4) vs live (mga1) and this seems fixed in newer python. I'm not sure it's worth trying to backport python fixes to mga1... I did look at a diff between the email code from current to mga1 but nothing obvious jumped out... I suspect it's probably related to the change to unicode strings by default in newer pythons...

Anyway, now I know what the problem is, I can probably work around it...
Comment 20 Colin Guthrie 2014-04-27 15:59:03 CEST
OK, I *think* I've fixed it but a real world test would be nice! It'll take a while to deploy via puppet, so please wait a couple hours before testing :) Feel free to close the bug if all seems well.
Comment 21 Thomas Backlund 2014-04-27 16:11:57 CEST
@colin

if you want to speed up puppet changes deployment, you can force it on affected servers with:

puppetd --test

CC: (none) => tmb

Comment 22 Mageia Robot 2014-04-27 21:04:14 CEST
commit 9ad628c85575b9a1270b8e31a7d80a5bbdcae763
Author: Verscheldé Foo <colin@...>
Date:   Sun Apr 27 20:04:10 2014 +0100

    Setting a date 8 mga#12374
---
 Commit Link:
   http://gitweb.mageia.org/software/test/commit/?id=9ad628c85575b9a1270b8e31a7d80a5bbdcae763
Comment 23 Colin Guthrie 2014-04-27 21:05:27 CEST
Yeah have done that a few times, but puppet takes so damn long to run, it's almost always quicker to just manually deploy the changes... (albeit it's not a proper test). I was running out the door anyway, so couldn't even do that this time.

Anyway, seems to have worked according to the previous notification :)

Please reopen if this resurfaces (or the whack-a-mole nature of bugs means I've broken something else instead :D)

Status: NEW => RESOLVED
Resolution: (none) => FIXED

Comment 24 Mageia Robot 2014-04-27 23:50:19 CEST
commit 73ca7216d66bfceb67b04d7dc766acca4375dbc4
Author: Rémi Verschelde <remi@...>
Date:   Sun Apr 27 23:50:13 2014 +0200

    Tésting if bùg mga#12374 is indèêd fixed - Thanks Ãolin!
---
 Commit Link:
   http://gitweb.mageia.org/software/test/commit/?id=73ca7216d66bfceb67b04d7dc766acca4375dbc4
Comment 25 Rémi Verschelde 2014-04-27 23:50:39 CEST
It works, many thanks!