crossbario / crossbario/autobahn-python

Application error arguments get encoded as bytes

Open
#1,101 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

needs-investigation Python 2
Dominant language
Python
Stars
2.5k
Forks
768
PR merge metrics
No merged PRs in 30d

Description

i ran across this weird behavior when using Autobahn-Js as a client for a backend made using Autobahn-Pyton, it seems that when using python 2.7 with msgpack serializer the arguments of an error get encoded as bytes. this causes them to end up in Base64 in a client that doesn't use msgpack .

to me this seems undesirable?

Backend component:

from autobahn.twisted.component import Component, run

def main(session, details):

    def test(val=5):
        return 100/val

    session.register(test, u'test.hello')

# Create wamp conn
server = Component(
    transports=[{
        'url': u'ws://localhost:9000',
        'serializers': ['msgpack']
    }],
    realm=u'test',
)
server.on_join(main)

if __name__ == "__main__":
    run([server])

Client:

from autobahn.twisted.component import Component, run

def main(session, details):

    session.call(u'test.hello',7)
    session.call(u'test.hello',0)
    print('Done')

# Create wamp conn
client = Component(
    transports=[{
        'url': u'ws://localhost:9000'
    }],
    realm=u'test',
)
client.on_join(main)

if __name__ == '__main__':
    run([client])

Running the backend and client gives the below output on the client

2019-01-16T16:03:23+0100 connecting once using transport type "websocket" over endpoint "tcp"
2019-01-16T16:03:23+0100 Starting factory <autobahn.twisted.websocket.WampWebSocketClientFactory object at 0x7fe1f4a3e550>
2019-01-16T16:03:23+0100 Done
2019-01-16T16:03:23+0100 Unhandled error in Deferred:
2019-01-16T16:03:23+0100 Traceback (most recent call last):
Failure: autobahn.wamp.exception.ApplicationError: ApplicationError(error=<wamp.error.runtime_error>, args=[u'aW50ZWdlciBkaXZpc2lvbiBvciBtb2R1bG8gYnkgemVybw=='], kwargs={}, enc_algo=None)

as can be seen a 'integer division or modulo by zero' causes this odd behavior to appear

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reproducing the Python 2.7 backend and Autobahn-JS client combination shown in the issue, using the msgpack serializer on the backend and triggering the division-by-zero error. Trace how the application error arguments are serialized and decoded; done means a client without msgpack receives the error text as readable arguments rather than Base64 bytes, with a regression test for this case.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript, python
Domain
api, backend
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.