Skip to content

Fix reconstructed JSON RPC error responses - #120

Open
bensynapse wants to merge 1 commit into
mbr:masterfrom
bensynapse:fix-jsonrpc-error-response
Open

bensynapse wants to merge 1 commit into
mbr:masterfrom
bensynapse:fix-jsonrpc-error-response

Conversation

@bensynapse

Copy link
Copy Markdown

I run Live Tennis API.

Addresses #116. JSONRPCError.error_respond() raises AttributeError because the constructor only sets _jsonrpc_error_code. Dictionary input also fails because it reads error.message.

The constructor now reads the dictionary message and exposes jsonrpc_error_code, while retaining the private attribute. Reconstructed errors can serialize again. A remote error forwarded through RPCClient and RPCDispatcher keeps its original code and structured data.

All 13 new cases fail before the fix. They cover both constructor inputs, empty messages, absent and explicit data, both protocol error modes, and dispatcher forwarding.

tox -e py passes in Docker on Python 3.10.22: 655 passed and 55 existing skips, including the coverage run. Both pytest commands from tox.ini also pass on Python 3.9.25. Source and wheel builds pass with python -m build --no-isolation.

The pinned gevent needs pkg_resources, so I installed setuptools<81 in the test environment. Without it, tox reports 15 WSGI fixture setup errors. Repository dependency pins are unchanged.

Read the message from the dictionary input and expose the error code used
by response creation and dispatcher forwarding. Keep the existing private
attribute for callers that already inspect it.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant