-
Notifications
You must be signed in to change notification settings - Fork 439
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
Method parameter conversion error handling logic should preserve JSON-RPC id from the request #290
Comments
…sion errors. Server used to output null as id value if some parameter conversion has been failed. Request id context was lost due to exceptions and null was sent to client. Fix contains more grained exception handling and restore of initial request context. Added also tests, which check for expected id result in the responses.
What is the best way to add validations for the API input parameters ? |
In my opinion, this framework should not deal with validation of users' business objects. The best option is to manually check the object just after framework has returned control into users' code. Current issue is not quite related to the object validation, an it descibes a bug about the JSON-RPC
How the framework will know which concrete implementation to inject into users' method? When remote methods are called via RPC, then data is exchanged between remote processes. If you really need this, then there are some interceptors provided by this framework, which may transform objects. |
#290: Fix JSON-RPC id output in case of method type conversion errors.
During upgrade to newer
1.6.0
version an error related to invalid handling of JSON-RPC id was discovered.Suppose you have a server with following interface:
When a valid json, but with invalid parameters, is sent to server:
Then server responds with
, where initial
id
value is lost.This is also true for the batch requests, where multiple requests are sent at once.
It should be possible to find a failed request by
id
from the response.The "JSON parse error"
-32700
is not really correct here because:Valid error probably should be the "Invalid params"
-32602
, because wrong parameter was sent.More detailed log (code line numbers may be wrong):
Variant with batching:
The behavior was correct in previous
1.5.3
version, but in1.6.0
server started to outputnull
values forid
in responses.This is caused by the recent change in the error handling logic:
https://github.com/briandilley/jsonrpc4j/blob/1.6.0/src/main/java/com/googlecode/jsonrpc4j/JsonRpcBasicServer.java#L466
The text was updated successfully, but these errors were encountered: