Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

iris_twilio Module Fails on urllib.urlencode() with Unicode Characters #316

Closed
p6knewman opened this issue Nov 16, 2017 · 1 comment
Closed

Comments

@p6knewman
Copy link
Contributor

I experienced an issue yesterday where a well-meaning user pasted in some output he received in PuTTY to the creation of an Iris incident. Within this output, I believe there were some unusual unicode quote characters that caused urllib.urlencode to fail to encode the payload inside the iris_twilio vendor module. The end result was that Twilio didn't trigger any phone calls or SMS messages and fell back to email because of all the unhandled exceptions.

Nov 15 19:17:20 iris-host iris[33482]: sender.1 | 2017-11-15 19:17:20,094 INFO root Sending message (ID 38) locally
Nov 15 19:17:20 iris-host iris[33482]: sender.1 | 2017-11-15 19:17:20,094 ERROR iris.vendors Sending {u'body': u'Blah blah blah some text about /etc/nginx/sites-available$ sudo ln -s /etc/nginx/sites-available/default_new /etc/nginx/sites-enabled/default\r\nln: failed to create symbolic link \xe2/etc/nginx/sites-enabled/default\xe2: File exists
Nov 15 19:17:20 iris-host iris[33482]: '} with vendor <iris.vendors.iris_twilio.iris_twilio object at 0x7f9b3faffcd0> failed
Nov 15 19:17:20 iris-host iris[33482]: sender.1 | Traceback (most recent call last):
Nov 15 19:17:20 iris-host iris[33482]: sender.1 |   File "/alldata/home/iris/iris/src/iris/vendors/__init__.py", line 64, in send_message
Nov 15 19:17:20 iris-host iris[33482]: sender.1 |     return vendor.send(message)
Nov 15 19:17:20 iris-host iris[33482]: sender.1 |   File "/alldata/home/iris/iris/src/iris/vendors/iris_twilio.py", line 143, in send
Nov 15 19:17:20 iris-host iris[33482]: sender.1 |     return self.modes[message['mode']](message)
Nov 15 19:17:20 iris-host iris[33482]: sender.1 |   File "/alldata/home/iris/iris/src/iris/vendors/iris_twilio.py", line 112, in send_call
Nov 15 19:17:20 iris-host iris[33482]: sender.1 |     self.config['relay_base_url'], urllib.urlencode(payload)
Nov 15 19:17:20 iris-host iris[33482]: sender.1 |   File "/usr/lib/python2.7/urllib.py", line 1343, in urlencode
Nov 15 19:17:20 iris-host iris[33482]: sender.1 |     v = quote_plus(str(v))
Nov 15 19:17:20 iris-host iris[33482]: sender.1 | UnicodeEncodeError: 'ascii' codec can't encode character u'\xe2' in position 350: ordinal not in range(128)

I believe this should be a straightforward fix of UTF-8 encoding the payload before urlencoding it. PR incoming, but let me know if you have something else in mind.

@jrgp
Copy link
Member

jrgp commented Dec 6, 2017

Closing as this PR was merged.

@jrgp jrgp closed this as completed Dec 6, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants