-
Notifications
You must be signed in to change notification settings - Fork 21
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
Some client JSON parsers don't support 64-bit integers, potentially causing truncation #50
Comments
I wonder if you've found a bug in your http / json client library but I will double check my end just in case! Would be helpful to know if you get a different result if you access from a different client/browser? |
It looks as if some client APIs (notably JavaScript) struggle with large numbers. While JSON specs support arbitrary sizes, there are limits based on safe interoperability. Options
I'm inclined to (3) because it would be easy, would support users on broken clients who don't have capability to fix the issue, and wouldn't introduce a breaking change for clients who have no difficulty in processing JSON with unsigned 64 bit integers. |
In favour of (2):
It will be informative to know how snowstorm and ontoserver handle this issue. |
It appears that snowstorm defaults to return ids as text. |
Hi Mark So while this has nothing to do with Hermes (and I agree there isn't a case for changing anything) I suspect other users will inadvertently run into this issue and will be happy to read this thread. |
The issue that concerns me is that there is silent data loss for some clients using JSON as the transport, even though admittedly this is a client problem. If there is a configurable per-request option, I could generate strings for identifiers instead of numbers in the JSON response, and then the issue a) is well documented and b) has a workaround baked in and c) mimics behaviour of other SNOMED servers. The counter-argument is that it adds complexity to both the surface API and the implementation. I will ponder for a bit before deciding. Does your quick fix work from R? |
Yes very much a client problem - type conversion being ubiquitous in R it seems the usual workarounds (using bit64 or character type casting) when loading data from database or from file directly are not operational here. |
The patch below adds per-request support for stringifying values that are a) of type 'long' and b) an 'id' property (ie property name ends in 'Id'. Another alternative is to add an option to the server (on startup) so that this is a per-server configuration rather than a per-request option. The per-request option would then override whatever the default setting would be in the running server. As you can see, it is quite trivial to add this functionality. However, there are situations in which this won't appropriately stringify results - such as when there are extended fields within a reference set item. Arguably that could be made to work, by looking at the refset descriptors carefully, but adds more complexity.
|
I think I found the workaround - undocumented argument of jsonlite ( As far as I'm concerned this works for me.
|
Thanks @peterdutey - that's helpful to know. I have added a warning in the documentation for the moment, and keep this issue open for a while. On a related issue, while I have not used R since my doctorate days, I wonder whether you had a view on a rjava-based library for Hermes so that you can use SNOMED CT in-process and avoid even local HTTP roundtrips? This is how I use in my own analytics from Clojure... although could switch to using an external server if I needed to do so. Hermes has a Java-friendly API already so that it should be easy to run from R? In that case, you'd have no issues with type coercions as you'd not serialise via JSON at all. |
Yes! I have been meaning to email you about this for several months about this... Email coming now! |
I am going to close this issue, but happy to consider re-opening. This is principally a client JSON decoding problem, and it sounds as if there are mitigations possible - e.g. in JavaScript or in R - as those libraries have recognised their problems with large numbers. The JSON specification does not limit numbers to a certain size, although I do recognise the warning re: practical interoperability based on implementation limits. The SNOMED specification defines identifiers to be unsigned 64-bit integers; it is reasonable to use strings or numbers representations. While it is straightforward to add a per-server or per-request option to turn identifiers into strings in the JSON output, it adds complexity when in fact most clients will have no trouble at all in dealing with 64-bit integers. |
Hello
First I'd like to say this is a much-needed library that's both incredibly fast and implements recent operators of the ECL.
I'm enjoying learning to use it!
I just came across a behaviour I don't quite understand for concepts in the UK drug extension, which have longer identifiers.
This first happened on my laptop and it seems the behaviour is similar using your helpful test server.
I do apologise in advance if the explanation should be obvious - I seem to be observing a change in the last digit of the concept ID of UK medical products. The two example below seem to affect all the REST endpoints I've tested.
I am wondering whether I'm missing something. The data stored seems valid, it's just the REST response doesn't match.
Curious to understand what is happening with the retrieval.
Thanks!
Peter
http://3.9.221.177:8080/v1/snomed/search?constraint=9401401000001101
You can see the concept id
9401401000001101
reads940140100000110
0
http://3.9.221.177:8080/v1/snomed/concepts/38001711000001104/preferred
You can see the concept id
38001711000001104
reads3800171100000110
0
The text was updated successfully, but these errors were encountered: