-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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
fix #17383: json.%,to and jsonutils.formJson,toJson now works with uint|uint64 #17389
Conversation
9e8773e
to
f2b84db
Compare
a56c5bd
to
f6d5b39
Compare
this should solve the most critical issue, though it's worth noting that it breaks backwards compatibility with earlier nim versions. an aside:
in general, also, the fix to this issue should ideally be backported to 1.2.x since the issue is present in 1.2.10 also - in some projects, this can turn into a security bug leading to remote exploits (since json data often comes from untrusted sources). |
IMO it's fine in this case:
this can be changed in future work, if needed; note that
not making it public means we can change implementation, and in fact #15776 might very well be a more efficient implementation, see #15768 (comment) we should however add an API import std/json
echo uint.high
let j = parseJson("184467440737095516159999999")
echo j.kind # JString
echo j.jsonKind # Number
see above, => see RFC nim-lang/RFCs#353
this opens a can of worms, because it'd also require backporting #15768; people should upgrade eventually or be ok living with some bugs |
we have users depending on this particular behavior and need to notify them in turn - providing a changelog and documenting the breaking behavior is just common sense, regardless if you consider the changed/original behavior buggy or not - in the end it breaks actual software out there for actual users. |
this would be a lot easier if the json module, and similar large modules that have no relationship to the language and compiler, were published outside the standard library - as is, upgrading nim, even between point versions, brings in a host of undesired changes that break backwards compatibility. |
adding changelog in #17400
whether or not this would be desirable, this is not as simple as what you describe.
Also, you've made the same comment recently, see my previous answer here: status-im/nim-libbacktrace#12 (comment) which has more details on this (dmd vs phobos split causing friction, monorepo benefits etc). Instead of scattering the discussion in review comments, please create a dedicated issue / RFC to discuss what you have in mind. |
So, to provide some background - the The fix was later backported to 1.2 - we're now trying to upgrade to 1.2.10, and are running into these bugs - they are significant from our point of view because they introduce remote exploits and require manually reviewing all conversions across the codebase - this is why, at minimum, a changelog entry should be natural to have - changes like these have implications for users of the language - I appreciate #17400! Regarding modules, I'm pointing it out in this issue that having modules standalone is easier for downstream users like us because it's such a practical and obvious case where having things in the standard library makes things hard - it can serve as background information in a future RFC - if json is used in the compiler, the compiler would simply depend on a json package that it pulls in as part of its build - or keep its own private copy for things it needs - this would also solve issues around bootstrapping where the standard library and compiler-used-to-compile-itself - same issue as |
it's often impossible to fix bugs without introducing some kind of regression, when users depend on prior behavior (which is why the 1.0 stability promise should be IMO taken with a grain of salt, as enforcing stability would prevent much needed bug fixes and improving the language); the patch vs minor distinction is useful as a general guideline but comes with this disclaimer. But yes, #15237 could've come with a changelog entry and could still be added retroactively (past changelogs are now version controlled)
related: please read this thread nim-lang/fusion#22 |
I'm having a very hard time to backport this to 1.2.x because it relies on stuff introduced later (e.g., but not limited to, @timotheecour Could you maybe make a variant of this PR catered specifically for 1.2.x, using stuff only available there, i.e. based on |
I don't think this should be backported, see note above: #17389 (comment) |
the reasonable thing for a backport would be to keep returning |
… with uint|uint64 (nim-lang#17389) [backport:1.2] * fix nim-lang#17383: json.%,to and jsonutils.formJson,toJson now works with uint|uint64 * fixup * fix for js
Co-authored-by: flywind <xzsflywind@gmail.com>
@arnetheduck How about we revert #15237 in the 1.2.x branch, so you get the old behaviour back in 1.2.12? |
@narimiran sgtm, it's a prudent solution given that other places in the standard library might have changed behavior as a side effect of that change - we're in the process of auditing our code base to deal with the new |
… with uint|uint64 (nim-lang#17389) [backport:1.2] * fix nim-lang#17383: json.%,to and jsonutils.formJson,toJson now works with uint|uint64 * fixup * fix for js
Co-authored-by: flywind <xzsflywind@gmail.com>
fix #17383