airflow-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Joseph Harris (JIRA)" <>
Subject [jira] [Created] (AIRFLOW-835) SMTP Mail delivery fails with server using CRAM-MD5 auth
Date Fri, 03 Feb 2017 18:09:51 GMT
Joseph Harris created AIRFLOW-835:

             Summary: SMTP Mail delivery fails with server using CRAM-MD5 auth
                 Key: AIRFLOW-835
             Project: Apache Airflow
          Issue Type: Bug
          Components: utils
    Affects Versions: Airflow 1.7.1
         Environment: (debian:jessie + python2.7 in docker)
            Reporter: Joseph Harris
            Priority: Minor

Traceback when sending email from smtp-server configured to offer CRAM-MD5 (in all cases,
tls included). This occurs because the configuration module returns the password as a futures.types.newstr,
instead of a plain str (see below for gory details of why this breaks).

Traceback (most recent call last):
  File "/usr/local/lib/python2.7/site-packages/airflow/", line 1308, in handle_failure
    self.email_alert(error, is_retry=False)
  File "/usr/local/lib/python2.7/site-packages/airflow/", line 1425, in email_alert
    send_email(, title, body)
  File "/usr/local/lib/python2.7/site-packages/airflow/utils/", line 43, in send_email
    return backend(to, subject, html_content, files=files, dryrun=dryrun)
  File "/usr/local/lib/python2.7/site-packages/airflow/utils/", line 79, in send_email_smtp
    send_MIME_email(SMTP_MAIL_FROM, to, msg, dryrun)
  File "/usr/local/lib/python2.7/site-packages/airflow/utils/", line 95, in send_MIME_email
  File "/usr/local/lib/python2.7/", line 607, in login
    (code, resp) = self.docmd(encode_cram_md5(resp, user, password))
  File "/usr/local/lib/python2.7/", line 571, in encode_cram_md5
    response = user + " " + hmac.HMAC(password, challenge).hexdigest()
  File "/usr/local/lib/python2.7/", line 75, in __init__
  File "/usr/local/lib/python2.7/site-packages/future/types/", line 390, in translate
    if ord(c) in table:
TypeError: 'in <string>' requires string as left operand, not int

SMTP configs:

email_backend =

smtp_host = {a_smtp_server}
smtp_port = 587
smtp_starttls = True
smtp_ssl = False
smtp_user = {a_username}
smtp_password = {a_password}
smtp_mail_from = {a_email_addr}

*Gory details
If the server offers CRAM-MD5, smptlib prefers this by default, and will try to use hmac.HMAC
to hash the password:

But if the password is a newstr, newstr.translate expects a dict mapping instead of str, and
raises an exception.

All of this occurs after a successful SMTP.ehlo(), so it's probably not crap container networking

Could be resolved by passing the smtp password as a futures.types.newbytes, as this behaves
as expected:

from future.types import newstr, newbytes
import hmac

# Make str / newstr types
test = 'a_string'
test_newstr = newstr(test)
test_newbytes = newbytes(test)

msg = 'future problems'

# Test 1 - Try to do a HMAC:
# fine
hmac.HMAC(test, msg)

# fails horribly
hmac.HMAC(test_newstr, msg)

# is completely fine
hmac.HMAC(test_newbytes, msg)

This message was sent by Atlassian JIRA

View raw message