Skip to content

Commit 6f0732b

Browse files
Frédéric Guillotlindycoder
authored andcommitted
Fix bug when callback params is empty
This patch fixes an AttributeError exception in router.py. Ubersmith send this callback payload for order modules: {'url': None, 'params': []} Ubersmith serialize an empty array to a list instead of a dict.
1 parent f6037c7 commit 6f0732b

File tree

2 files changed

+6
-0
lines changed

2 files changed

+6
-0
lines changed

tests/test_router.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,3 +72,7 @@ def test_list_implemented_methods(self):
7272
def test_accept_callback_as_kwarg(self):
7373
self.router.invoke_method(module=self.module1, method='hello', params=[], env={},
7474
callback={'url': 'http://example.net', 'params': {'k1': 'v1', 'k2': 'v2'}})
75+
76+
def test_callback_has_empty_params_list(self):
77+
self.router.invoke_method(module=self.module1, method='hello', params=[], env={},
78+
callback={'url': 'http://example.net', 'params': []})

ubersmith_remote_module_server/router.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,8 @@ def invoke_method(self, module, method, params=None, env=None, callback=None):
3737
def _build_request_context(self, callback):
3838
callback = callback or {}
3939
params = callback.get('params', {})
40+
if isinstance(params, list):
41+
params = dict()
4042
return RequestContext(callback_url=callback.get('url'),
4143
module_id=params.get('module_id'),
4244
device_id=params.get('device_id'),

0 commit comments

Comments
 (0)