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

JSONRPCResponseManager.handle silences the exception if "id" is not passed #124

Open
faerot opened this issue Sep 21, 2022 · 0 comments
Open

Comments

@faerot
Copy link

faerot commented Sep 21, 2022

Description

There is no way to handle exceptions if request does not pass "id" attribute. JSONRPCResponseManager.handle() should always return a response with an error in case of exception in user code or if it is not possible, there should be an argument to enable this (strict) behavior.

Steps to Reproduce

Run this code:

import jsonrpc

dispatcher = jsonrpc.Dispatcher()

@dispatcher.add_method
def test():
    1/0

request = '{"jsonrpc": "2.0", "method": "test", "params": []}'

print(jsonrpc.JSONRPCResponseManager.handle(request, dispatcher))

Expected behavior: error response should be printed

Actual behavior: None is printed

Reproduces how often: always

Versions

all

Additional Information

If you change request to '{"jsonrpc": "2.0", "method": "test", "params": [], "id": 1}' it expectedly returns response with an error:

{'jsonrpc': '2.0', 'id': 1, 'error': {'message': 'Server error', 'code': -32000, 'data': {'message': 'integer division or modulo by zero', 'args': ('integer division or modulo by zero',), 'type': 'ZeroDivisionError'}}}
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

No branches or pull requests

1 participant