crossbario / crossbario/autobahn-python
After upgrade to Python 3.5.0a3 assertion failure results in wamp.error.cannot_authenticate
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 2.5k
- Forks
- 768
- PR merge metrics
- No merged PRs in 30d
Description
Today I installed a new Python 3.5.0a3 virtualenv and pip installed autobahn 0.10.9. I then ran an application that was working fine under Python 3.4 and got a very uniformative error:
wamp.error.cannot_authenticate:
Doing a little digging, I can see this is the message sent back in wamp/protocol.py in onMessage in the errback added to the onChallenge call.
The first problem is that no information is printed about the error. I took a look at err.value and it is an AssertionError instance. Then I imported traceback and called traceback.print_tb(err._traceback) and it showed me:
File "/Users/terry/.virtualenvs/lm3/lib/python3.5/site-packages/txaio/aio.py", line 327, in done
res = f.result()
File "/usr/local/Cellar/python3/3.5.0a3/Frameworks/Python.framework/Versions/3.5/lib/python3.5/asyncio/futures.py", line 275, in result
raise self._exception
File "/Users/terry/.virtualenvs/lm3/lib/python3.5/site-packages/txaio/aio.py", line 271, in as_future
res = fun(*args, **kwargs)
File "/Users/terry/dark-matter/light-matter/light/autobahn/component.py", line 18, in onChallenge
challenge.extra['challenge'])
File "/Users/terry/.virtualenvs/lm3/lib/python3.5/site-packages/autobahn/wamp/auth.py", line 235, in compute_wcs
assert(type(challenge) == bytes)
I printed out type(challenge) and it's a str. Its value is the str representation of a dict:
{"nonce": "0Edxh609UnVkMv6X", "authprovider": "dynamic", "authid": "database", "timestamp": "2015-09-21T22:21:37.667Z", "authrole": "database", "authmethod": "wampcra", "session": 4486509142781041}
So it seems that something that used to be bytes in Python 3.4 is now a str...
It would be good if the error message actually said what went wrong, and of course good if the assertion didn't fail!
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start in wamp/protocol.py at onMessage and its onChallenge errback, then inspect autobahn/wamp/auth.py around compute_wcs and its bytes assertion. Reproduce the Python 3.5 failure and make the authentication error expose the underlying problem while handling the challenge value consistently; done means the reported authentication flow no longer fails on the shown str value.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- authentication
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100