praekeltfoundation / vumi

Messaging engine for the delivery of SMS, Star Menu and chat messages to diverse audiences in emerging markets and beyond.
BSD 3-Clause "New" or "Revised" License
421 stars 131 forks source link

Provider middleware fails when to_addr is None. #928

Closed hodgestar closed 9 years ago

hodgestar commented 9 years ago
2015-03-09 08:49:52+0000 Unhandled Error
        Traceback (most recent call last):
          File "/var/praekelt/vumi-go/ve/src/vumi/vumi/connectors.py", line 65, in handler
            return self._consume_message(mtype, msg)
          File "/var/praekelt/vumi-go/ve/src/vumi/vumi/connectors.py", line 89, in _consume_message
            d = self._middlewares.apply_consume(mtype, msg, self.name)
          File "/var/praekelt/vumi-go/ve/src/vumi/vumi/middleware/base.py", line 216, in apply_consume
            self.consume_middlewares, handler_name, message, connector_name)
          File "/var/praekelt/vumi-go/ve/local/lib/python2.7/site-packages/twisted/internet/defer.py", line 1237, in unwindGenerator
            return _inlineCallbacks(None, gen, Deferred())
        --- <exception caught here> ---
          File "/var/praekelt/vumi-go/ve/local/lib/python2.7/site-packages/twisted/internet/defer.py", line 1099, in _inlineCallbacks
            result = g.send(result)
          File "/var/praekelt/vumi-go/ve/src/vumi/vumi/middleware/base.py", line 206, in _handle
            message = yield handler(message, connector_name)
          File "/var/praekelt/vumi-go/ve/src/vumi/vumi/middleware/base.py", line 115, in handle_consume_outbound
            return self.handle_outbound(message, connector_name)
          File "/var/praekelt/vumi-go/ve/src/vumi/vumi/middleware/provider_setter.py", line 134, in handle_outbound
            message["provider"] = self.get_provider(message["to_addr"])
          File "/var/praekelt/vumi-go/ve/src/vumi/vumi/middleware/provider_setter.py", line 123, in get_provider
            if from_addr.startswith(prefix):
        exceptions.AttributeError: 'NoneType' object has no attribute 'startswith'
hodgestar commented 9 years ago

Ready for review.

justinvdm commented 9 years ago

:+1: