crossbario / crossbario/autobahn-python

HTTP headers causing exception in debug

Open
#608 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

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

Description

KeyError exception experienced using asyncio, with txaio logging level at debug, when performing WAMP handshake.

A debug logging statement in asyncio.websocket.protocol.WebSocketServerProtocol.processHandshake receives the HTTP header dict cast to a string. This seems to be read as part of the formatting, causing a KeyError to be raised from the logger during interpolation, as the tokens visible between the braces are not present in kwargs.

Example output:

2016-03-01T15:17:02 Exception in callback WebSocketAdapterProtocol._consume.<locals>.process(<Future finished result=None>) at /usr/local/lib/python3.4/dist-packages/autobahn/asyncio/websocket.py:105

I tried to see where this had come in, but it seems to happen in master, and is not obvious following git blame back (at least to me!) - can bisect if desired. Also, not sure whether the preferred solution is to have the braces escaped or a dict passed.

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 at autobahn/websocket/protocol.py, in asyncio.websocket.protocol.WebSocketServerProtocol.processHandshake around line 3484, and inspect the debug logging statement that formats the HTTP header dictionary. Reproduce a WAMP handshake with txaio logging at debug level. Done means the handshake no longer raises KeyError while interpolating the logged headers.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
backend, networking
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
42/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.