Closed bitboxer closed 3 years ago
Hi @bitboxer, yes we should mention that. Technically JSON-RPC can also accept numbers as IDs but since we use the IDs for routing messages and internally convert them into strings of the form [operator].[service](id)
we don't allow that. We could of course implement conversion but that might cause surprising behavior (e.g. you pass in an ID that could be a number but is passed as a string, and we convert it to a number when passing it back).
We also don't allow NULL
values as we need the IDs for routing and as asynchronous requests wouldn't be identifiable otherwise.
Hm, that might not be possible to change depending on what library the clients use. I already have a fork of an outdated gem to make it work with latest Rails, for me it's not a problem to add that behavior to it. Others might not be so "lucky" 😀.
Ok, I understand. I'll think about how we can make this work.
So I think we can implictly convert numbers to strings (though as I said this might cause unexpected behavior in some cases) and auto-generate IDs for requests that don't include one. This'll be in the next release today or tomorrow.
Hey @bitboxer, so we've added support for numerical and null
IDs to the JSON-RPC endpoint.
We will convert numerical IDs, annotate them and and convert them back automatically, so you shouldn't notice a difference. Edge cases (i.e. string IDs that match our custom number encoding format) should also be handled correctly. Requests with a null
ID will get assigned a random 16-byte ID which you need to store in case you need to track the request.
If the problem persists please reopen this ticket.
Please note that Golang represents numerical IDs as float64
objects in JSON, so for very large IDs (e.g. 2444444444444444444
) the back-and-forth conversion will yield incorrect values. We advise against using long integer IDs in requests for that reason.
Okay, will add a setting to make IDs strings in the library I am using.
I tried to send the demo message with my ruby code, but sadly the payload does not work if the JSON contains a number for the id:
The spec defines the ID as
MUST contain a String, Number, or NULL
so this might be a bug?