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

1.0 Specification error field #13

Open
bbkr opened this issue Dec 29, 2011 · 1 comment
Open

1.0 Specification error field #13

bbkr opened this issue Dec 29, 2011 · 1 comment

Comments

@bbkr
Copy link

bbkr commented Dec 29, 2011

Spec 1.0 says that "error" must be "An Error object" without precising it.

However library assumes that "error" is returned in 2.0 spec format - with mandatory "code" and "error" keys - even if jsonrpclib.config.version is set to 1.0.

So if you connect to valid 1.0 server and get valid "error":{"reason":"something"} response you get KeyError exception instead of error content.

Lines that cause problem:
https://github.com/joshmarshall/jsonrpclib/blob/master/jsonrpclib/jsonrpc.py#L527-528

@dawryn
Copy link

dawryn commented Sep 14, 2012

I also came up to the same problem. Version is not used in response dispatcher.
Solution:

diff --git a/jsonrpclib/SimpleJSONRPCServer.py b/jsonrpclib/SimpleJSONRPCServer.py
index d76da73..ec383a1 100644
--- a/jsonrpclib/SimpleJSONRPCServer.py
+++ b/jsonrpclib/SimpleJSONRPCServer.py
@@ -105,7 +105,8 @@
         try:
             response = jsonrpclib.dumps(response,
                                         methodresponse=True,
-                                        rpcid=request['id']
+                                        rpcid=request['id'],
+                                        version=get_version(request)
                                         )
             return response
         except:

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

2 participants