Bug 215330

Summary: [ews] Handle logs with unicode characters in ews emails
Product: WebKit Reporter: Aakash Jain <aakash_jain>
Component: Tools / TestsAssignee: Aakash Jain <aakash_jain>
Status: RESOLVED FIXED    
Severity: Normal CC: aakash_jain, ap, darin, dewei_zhu, jbedard, ryanhaddad, webkit-bug-importer
Priority: P2 Keywords: InRadar
Version: Other   
Hardware: Unspecified   
OS: Unspecified   
See Also: https://bugs.webkit.org/show_bug.cgi?id=215174
https://bugs.webkit.org/show_bug.cgi?id=215627
Attachments:
Description Flags
Patch darin: review+

Description Aakash Jain 2020-08-10 12:21:27 PDT
We added relevant log information in ews emails in r265302. However, logs with unicode characters results in following exception. We should handle them properly.

        Traceback (most recent call last): 
          File "/usr/lib64/python2.7/site-packages/twisted/internet/defer.py", line 1475, in gotResult
            _inlineCallbacks(r, g, status)
          File "/usr/lib64/python2.7/site-packages/twisted/internet/defer.py", line 1421, in _inlineCallbacks
            status.deferred.callback(getattr(e, "value", None)) 
          File "/usr/lib64/python2.7/site-packages/twisted/internet/defer.py", line 460, in callback
            self._startRunCallbacks(result)
          File "/usr/lib64/python2.7/site-packages/twisted/internet/defer.py", line 568, in _startRunCallbacks
            self._runCallbacks()
        --- <exception caught here> ---
          File "/usr/lib64/python2.7/site-packages/twisted/internet/defer.py", line 654, in _runCallbacks
            current.result = callback(current.result, *args, **kw)
          File "steps.py", line 1401, in <lambda>
            d.addCallback(lambda res: self.analyzeResults())
          File "steps.py", line 1422, in analyzeResults
            self.send_email_for_new_build_failure()
          File "steps.py", line 1492, in send_email_for_new_build_failure
            email_text += '\n\nError lines:\n\n{}'.format(logs)
        exceptions.UnicodeEncodeError: 'ascii' codec can't encode character u'\u2018' in position 108: ordinal not in range(128)
Comment 1 Aakash Jain 2020-08-10 12:24:46 PDT
Created attachment 406318 [details]
Patch
Comment 2 Aakash Jain 2020-08-10 12:36:04 PDT
Committed r265442: <https://trac.webkit.org/changeset/265442>
Comment 3 Radar WebKit Bug Importer 2020-08-10 12:37:56 PDT
<rdar://problem/66794326>
Comment 4 dewei_zhu 2020-08-10 12:41:55 PDT
Comment on attachment 406318 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=406318&action=review

> Tools/BuildSlaveSupport/ews-build/send_email.py:43
> +    email_data = """From: {}\nTo: {}\nSubject: {}\n\n{}""".format(FROM_EMAIL, ', '.join(to_emails), subject, text.encode('utf-8'))

Any reason that we don't do it for `subject`?
Comment 5 Aakash Jain 2020-08-10 13:08:41 PDT
(In reply to dewei_zhu from comment #4)
> Any reason that we don't do it for `subject`?
Good point. Let me do that in a separate patch.
Comment 6 Jonathan Bedard 2020-08-11 09:21:30 PDT
Comment on attachment 406318 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=406318&action=review

>> Tools/BuildSlaveSupport/ews-build/send_email.py:43
>> +    email_data = """From: {}\nTo: {}\nSubject: {}\n\n{}""".format(FROM_EMAIL, ', '.join(to_emails), subject, text.encode('utf-8'))
> 
> Any reason that we don't do it for `subject`?

Fine for now, but. this may be a case for using webkitcorepy, because this encoding will be unneeded in Python 3.