Here is the log from the original error.
[03/May/2017:11:56:47 +0200] GNCRN <726> 127.0.0.1 rqt:6.435311 200 3396 "POST:/Converter/changeset/ce4b9a3b0e7826725d41fa58d8269d4293f17b17/comment " usr:- "stuff"
2017-05-03 12:01:50.889 INFO [rhodecode.lib.base] IP: <ip> User: <AuthUser('id:2[<username>] ip:<ip> auth:True')> accessed /Converter/changeset/ce4b9a3b0e7826725d41fa58d8269d4293f17b17/comment [changeset.comment]
2017-05-03 12:01:51.010 INFO [rhodecode.lib.auth] user <AuthUser('id:2[<username>] ip:<ip> auth:True')> authenticating with:RHODECODE_AUTH IS authenticated on func ChangesetController:comment
2017-05-03 12:01:51.659 INFO [root] MAIL SEND TO: [u'<validemailaddress>']
2017-05-03 12:01:51.682 ERROR [rhodecode.lib.celerylib.tasks] Mail sending failed
Traceback (most recent call last):
File "/opt/rhodecode/store/9q264m389m52myrgjanjivaab4192bva-python2.7-rhodecode-enterprise-ce-4.7.2/lib/python2.7/site-packages/rhodecode/lib/celerylib/tasks.py", line 100, in send_email
m.send(recipients, subject, body, html_body)
File "/opt/rhodecode/store/9q264m389m52myrgjanjivaab4192bva-python2.7-rhodecode-enterprise-ce-4.7.2/lib/python2.7/site-packages/rhodecode/lib/rcmail/smtp_mailer.py", line 84, in send
raw_msg = msg.to_message()
File "/opt/rhodecode/store/9q264m389m52myrgjanjivaab4192bva-python2.7-rhodecode-enterprise-ce-4.7.2/lib/python2.7/site-packages/rhodecode/lib/rcmail/message.py", line 87, in to_message
self.validate()
File "/opt/rhodecode/store/9q264m389m52myrgjanjivaab4192bva-python2.7-rhodecode-enterprise-ce-4.7.2/lib/python2.7/site-packages/rhodecode/lib/rcmail/message.py", line 147, in validate
if self.is_bad_headers():
BadHeaders
2017-05-03 12:01:51.684 INFO [rhodecode.lib.utils] Logging action:`user_commented_revision:ce4b9a3b0e7826725d41fa58d8269d4293f17b17` on repo:`<Repository('9:Converter')>` by user:<User('id:2:<username>')> ip:<ip>
Then I printed out what caused the error with a custom exception(Notice the linefeed):
Traceback (most recent call last):
File "/opt/rhodecode/store/9q264m389m52myrgjanjivaab4192bva-python2.7-rhodecode-enterprise-ce-4.7.2/lib/python2.7/site-packages/rhodecode/lib/celerylib/tasks.py", line 100, in send_email
m.send(recipients, subject, body, html_body)
File "/opt/rhodecode/store/9q264m389m52myrgjanjivaab4192bva-python2.7-rhodecode-enterprise-ce-4.7.2/lib/python2.7/site-packages/rhodecode/lib/rcmail/smtp_mailer.py", line 84, in send
raw_msg = msg.to_message()
File "/opt/rhodecode/store/9q264m389m52myrgjanjivaab4192bva-python2.7-rhodecode-enterprise-ce-4.7.2/lib/python2.7/site-packages/rhodecode/lib/rcmail/message.py", line 87, in to_message
self.validate()
File "/opt/rhodecode/store/9q264m389m52myrgjanjivaab4192bva-python2.7-rhodecode-enterprise-ce-4.7.2/lib/python2.7/site-packages/rhodecode/lib/rcmail/message.py", line 147, in validate
if self.is_bad_headers():
File "/opt/rhodecode/store/9q264m389m52myrgjanjivaab4192bva-python2.7-rhodecode-enterprise-ce-4.7.2/lib/python2.7/site-packages/rhodecode/lib/rcmail/message.py", line 129, in is_bad_headers
raise Exception("Bad Header:" + val + "%%%")
Exception: Bad Header:[RhodeCode] [mention]
<username> (RhodeCode Admin) left note on commit `r1:ce4b9a3b0e78` in the Converter repository%%%
And the obvious final fix for this was:
def is_bad_headers(self):
"""
Checks for bad headers i.e. newlines in subject, sender or recipients.
"""
headers = [self.subject, self.sender]
headers += list(self.send_to)
headers += self.extra_headers.values()
for index, val in enumerate(headers):
headers[index] = val.strip()
return False
#for val in headers:
# for c in '\r\n':
# if c in val:
# return True
#return False
But then again… How did the linefeed get there ?