-
Notifications
You must be signed in to change notification settings - Fork 21.3k
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] Fix Activesupport json encode for hash with duplicate keys #50489
[FIX] Fix Activesupport json encode for hash with duplicate keys #50489
Conversation
87caac1
to
2700716
Compare
2700716
to
94a4adb
Compare
cc: @byroot |
…-json-encode [FIX] Fix Activesupport json encode for hash with duplicate keys
Thanks, I backported it to 7-1-stable. We should fix it in flori/json too though. |
Thanks for merging it @byroot T . This is my first contribution to rails. Looking forward to more. Yeah, I'll do it in |
@byroot I have fixed it in flori/json as well. Could you kindly review it? |
Sorry I missed this change at the time, I don't think we should have merged this. At some point we have to have a limit on how much double checking Rails does of the user's input and I think this is well within the area we should be "garbage in/garbage out". Being forced to support this really paints us into a corner in how we can implement this. I'd also argue that I'd actually prefer |
Yeah feel free to revert. |
…esupport-json-encode" This reverts commit 7b9e9ee, reversing changes made to 590a675. Reason: #50489 (comment)
…esupport-json-encode" This reverts commit 7b9e9ee, reversing changes made to 590a675. Reason: #50489 (comment)
…esupport-json-encode" This reverts commit 7b9e9ee, reversing changes made to 590a675. Reason: #50489 (comment)
I reverted to not block the release |
Fix: #50481
Motivation / Background
This Pull Request has been created because to fix #50481
The output for the hash is inconsistent when using
ActiveSupport::JSON.encode
with the duplicate key inRAILS_VERSION=7.1.0
. Specifically, if we examine the result below, the key 'a' appears twice in the output JSON for the same key 'a'.For
RAILS_VERSION=7.0.8
, it behaves as expected. Key is only once with later value.For example:
Result:
"{\"a\":1,\"a\":2}"
This behavior is not observed in
RAILS_VERSION=7.0.8
.Checklist
Before submitting the PR make sure the following are checked:
[Fix #50481]