Skip to content

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

@faerot

Description

@faerot

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'}}}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions