praekelt/vumi-go — pull request #770 by hodgestar (2013-11-13 17:08:50+00:00)
Title: HTTP API transport should not accept messages where the to_addr or from_addr are not unicode strings.

Example traceback:

```python
2013-11-13 15:02:43+0000 [VumiRedis,client] Unhandled Error
Traceback (most recent call last):
File "/var/praekelt/vumi-go/ve/local/lib/python2.7/site-packages/twisted/internet/defer.py", line 421, in errback
self._startRunCallbacks(fail)
File "/var/praekelt/vumi-go/ve/local/lib/python2.7/site-packages/twisted/internet/defer.py", line 488, in _startRun
Callbacks
self._runCallbacks()
File "/var/praekelt/vumi-go/ve/local/lib/python2.7/site-packages/twisted/internet/defer.py", line 575, in _runCallb
acks
current.result = callback(current.result, *args, **kw)
File "/var/praekelt/vumi-go/ve/local/lib/python2.7/site-packages/twisted/internet/defer.py", line 1126, in gotResul
t
_inlineCallbacks(r, g, deferred)
--- ---
File "/var/praekelt/vumi-go/ve/local/lib/python2.7/site-packages/twisted/internet/defer.py", line 1068, in _inlineC
allbacks
result = result.throwExceptionIntoGenerator(g)
File "/var/praekelt/vumi-go/ve/local/lib/python2.7/site-packages/twisted/python/failure.py", line 389, in throwExceptionIntoGenerator
return g.throw(self.type, self.value, self.tb)
File "/var/praekelt/vumi-go/go/apps/http_api/resource.py", line 161, in handle_PUT
yield self.handle_PUT_send_to(request, payload)
File "/var/praekelt/vumi-go/ve/local/lib/python2.7/site-packages/twisted/internet/defer.py", line 1068, in _inlineCallbacks
result = result.throwExceptionIntoGenerator(g)
File "/var/praekelt/vumi-go/ve/local/lib/python2.7/site-packages/twisted/python/failure.py", line 389, in throwExceptionIntoGenerator
return g.throw(self.type, self.value, self.tb)
File "/var/praekelt/vumi-go/go/apps/http_api/resource.py", line 215, in handle_PUT_send_to
to_addr, content, endpoint='default', **msg_options)
File "/var/praekelt/vumi-go/ve/local/lib/python2.7/site-packages/twisted/internet/defer.py", line 1068, in _inlineCallbacks
result = result.throwExceptionIntoGenerator(g)
File "/var/praekelt/vumi-go/ve/local/lib/python2.7/site-packages/twisted/python/failure.py", line 389, in throwExceptionIntoGenerator
return g.throw(self.type, self.value, self.tb)
File "/var/praekelt/vumi-go/ve/src/vumi/vumi/middleware/base.py", line 121, in _handle
message = yield handler(message, connector_name)
File "/var/praekelt/vumi-go/ve/local/lib/python2.7/site-packages/twisted/internet/defer.py", line 1068, in _inlineCallbacks
result = result.throwExceptionIntoGenerator(g)
File "/var/praekelt/vumi-go/ve/local/lib/python2.7/site-packages/twisted/python/failure.py", line 389, in throwExceptionIntoGenerator
return g.throw(self.type, self.value, self.tb)
File "/var/praekelt/vumi-go/go/vumitools/middleware.py", line 337, in handle_outbound
yield self.store.add_outbound_message(message, batch_id=batch_id)
File "/var/praekelt/vumi-go/ve/local/lib/python2.7/site-packages/twisted/internet/defer.py", line 1068, in _inlineCallbacks
result = result.throwExceptionIntoGenerator(g)
File "/var/praekelt/vumi-go/ve/local/lib/python2.7/site-packages/twisted/python/failure.py", line 389, in throwExceptionIntoGenerator
return g.throw(self.type, self.value, self.tb)
File "/var/praekelt/vumi-go/ve/src/vumi/vumi/components/message_store.py", line 215, in add_outbound_message
yield self.cache.add_outbound_message(batch_id, msg)
File "/var/praekelt/vumi-go/ve/local/lib/python2.7/site-packages/twisted/internet/defer.py", line 1070, in _inlineCallbacks
result = g.send(result)
File "/var/praekelt/vumi-go/ve/src/vumi/vumi/components/message_store_cache.py", line 141, in add_outbound_message
yield self.add_to_addr(batch_id, msg['to_addr'], timestamp)
File "/var/praekelt/vumi-go/ve/src/vumi/vumi/components/message_store_cache.py", line 238, in add_to_addr
to_addr.encode('utf-8'): timestamp,
exceptions.AttributeError: 'int' object has no attribute 'encode'
```