API methods without arguments fail when "args":null

Issue #702 resolved
Ton Plomp
created an issue

If I call an API method where there are no arguments (get_users) for instance and my JSON Post data looks like: {"id":1,"api_key":"xxxxxxxxxxxxxxxxx","method":"get_users","args":null}

Rhodecode returns an error 5000.

However if the args is an empty object: {"id":1,"api_key":"xxxxxxxxxxxxxxxxx","method":"get_users","args":{}} all goes well.

So the parser should detect a null and see it as an empty object.

In the log the following is returned:

URL: http://code.dekiwiki.net4c.net/_admin/api
Module weberror.errormiddleware:162 in __call__
>>  app_iter = self.application(environ, sr_checker)
Module beaker.middleware:155 in __call__
>>  return self.wrap_app(environ, session_start_response)
Module routes.middleware:131 in __call__
>>  response = self.app(environ, start_response)
Module pylons.wsgiapp:107 in __call__
>>  response = self.dispatch(controller, environ, start_response)
Module pylons.wsgiapp:312 in dispatch
>>  return controller(environ, start_response)
Module rhodecode.controllers.api:196 in __call__
>>  if (default == default_empty and arg not in self._request_params):
TypeError: argument of type 'NoneType' is not iterable
CGI Variables
CONTENT_TYPE    'text/plain; charset="utf-8"'
HTTP_HOST   'code.dekiwiki.net4c.net'
HTTP_USER_AGENT 'National Instruments LabVIEW'
HTTP_X_FORWARDED_HOST   'code.dekiwiki.net4c.net'
PATH_INFO   '/_admin/api'
WSGI Variables
application <beaker.middleware.SessionMiddleware object at 0xb0c47ac>
beaker.get_session  <bound method SessionMiddleware._get_session of <beaker.middleware.SessionMiddleware object at 0xb0c47ac>>
beaker.session  {'_accessed_time': 1356597124.5801549, '_creation_time': 1356597124.5801549}
paste.httpserver.thread_pool    <paste.httpserver.ThreadPool object at 0xa03426c>
paste.registry  <paste.registry.Registry object at 0xb2b34ec>
paste.throw_errors  True
pylons.controller   <rhodecode.controllers.api.api.ApiController object at 0xba293ec>
pylons.environ_config   {'session': 'beaker.session', 'cache': 'beaker.cache'}
pylons.pylons   <pylons.util.PylonsContext object at 0xba295ac>
pylons.routes_dict  {'action': u'index', 'controller': u'api/api'}
routes.route    <routes.route.Route object at 0xae93a6c>
routes.url  <routes.util.URLGenerator object at 0xb61552c>
webob.adhoc_attrs   {'language': 'en-us'}
wsgi process    'Multithreaded'
wsgi._org_proto 'http'
wsgiorg.routing_args    (<routes.util.URLGenerator object at 0xb61552c>, {'action': u'index', 'controller': u'api/api'})

Comments (2)

  1. Log in to comment