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

Specific type check behavior #1322

Closed
oberstet opened this issue Feb 20, 2020 · 1 comment · Fixed by #1405
Closed

Specific type check behavior #1322

oberstet opened this issue Feb 20, 2020 · 1 comment · Fixed by #1405

Comments

@oberstet
Copy link
Contributor

consider this registered procedure:

    @wamp.register('network.xbr.console.get_member_logins', check_types=True)
    def get_member_logins(self, member_oid: bytes, details: Optional[CallDetails] = None) -> list:

when this procedure is called with 2 (!) arguments, the resulting traceback is:

2020-02-20T21:59:49+0100 [Router      19483] XbrNetworkApi.onUserError(): "AttributeError: __name__"
Traceback (most recent call last):
  File "/home/oberstet/scm/crossbario/autobahn-python/autobahn/wamp/protocol.py", line 1020, in onMessage
    on_reply = txaio.as_future(endpoint.fn, *invoke_args, **invoke_kwargs)
  File "/home/oberstet/scm/crossbario/txaio/txaio/tx.py", line 365, in as_future
    return ensureDeferred(fun(*args, **kwargs))
  File "/home/oberstet/cpy381_3/lib/python3.8/site-packages/twisted/internet/defer.py", line 911, in ensureDeferred
    return _cancellableInlineCallbacks(coro)
  File "/home/oberstet/cpy381_3/lib/python3.8/site-packages/twisted/internet/defer.py", line 1529, in _cancellableInlineCallbacks
    _inlineCallbacks(None, g, status)
--- <exception caught here> ---
  File "/home/oberstet/cpy381_3/lib/python3.8/site-packages/twisted/internet/defer.py", line 1418, in _inlineCallbacks
    result = g.send(result)
  File "/home/oberstet/scm/crossbario/autobahn-python/autobahn/wamp/protocol.py", line 508, in _type_check
    "'{}' required={} got={}".format(name, kind.__name__, type(arguments[name]).__name__))
  File "/home/oberstet/cpy381/lib/python3.8/typing.py", line 757, in __getattr__
    raise AttributeError(attr)
builtins.AttributeError: __name__

this is super-obscure and unexpected ..

when turning off type checks, it will run into the assert within the procedure body:

2020-02-20T22:02:07+0100 Traceback (most recent call last):
  File "/home/oberstet/cpy381_3/lib/python3.8/site-packages/twisted/internet/defer.py", line 654, in _runCallbacks
    current.result = callback(current.result, *args, **kw)
  File "/home/oberstet/cpy381_3/lib/python3.8/site-packages/twisted/internet/defer.py", line 1475, in gotResult
    _inlineCallbacks(r, g, status)
  File "/home/oberstet/cpy381_3/lib/python3.8/site-packages/twisted/internet/defer.py", line 1416, in _inlineCallbacks
    result = result.throwExceptionIntoGenerator(g)
  File "/home/oberstet/cpy381_3/lib/python3.8/site-packages/twisted/python/failure.py", line 512, in throwExceptionIntoGenerator
    return g.throw(self.type, self.value, self.tb)
--- <exception caught here> ---
  File "./backend/test/test_api_login.py", line 72, in onJoin
    await self._onJoin(details)
  File "./backend/test/test_api_login.py", line 149, in _onJoin
    pubkeys = await self.call('network.xbr.console.get_member_logins', member_oid, vaction_code)
autobahn.wamp.exception.ApplicationError: ApplicationError(error=<wamp.error.runtime_error>, args=['details must be `autobahn.wamp.types.CallDetails`, but was `JEJX-5S3F-XWMF`'], kwargs={}, enc_algo=None, callee=None, callee_authid=None, callee_authrole=None, forward_for=None)
@oberstet
Copy link
Contributor Author

so on the user side, I was doing (wrong):

pubkeys = await self.call('network.xbr.console.get_member_logins', member_oid, vaction_code)

whereas I should have done (correct):

pubkeys = await self.call('network.xbr.console.get_member_logins', member_oid)

this is obviously quite a bad trap for beginner (I know enough details so I was able to find out the real issue quickly .. but without knowledge of inner mechanics, could be annoying ..)

@om26er om26er self-assigned this Feb 20, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants