-
Notifications
You must be signed in to change notification settings - Fork 153
Feature request: deep sort payload hashing #2120
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
Comments
I would like to take this and submit a PR. |
Hi @karthikeyanjp, sounds good! If you have any questions please feel free to ask. |
Hi @karthikeyanjp, I just wanted to check if you're still working on this or if I should put back the issue on the backlog. |
Putting the issue back on the backlog, if anyone is interested in picking this up please leave a comment! |
Should this And after implementing the function it should be used in these places right? |
Hi @arnabrahman, yes that would be ideal, but it's not a strict requirement since it's used only there for now. Regarding the usage, yes these are the places that come to mind. Are you interested in contributing? |
Yes, i am interested. @dreamorosi |
Great! I'll assign the issue to you then |
I have started working on it and have some followup questions. So if I understood the proposed solution correctly, it's only sorting the So, I am assuming for arrays we will honor the ordering & leave it Meaning, that for these two scenarios, the requests are not idempotent (array orderings are different)?
|
Hi @arnabrahman, thanks for the update. I did not think about arrays, but you make a good point. I think if possible we should include arrays as part of this issue together with objects, so that requests like the one in your example are idempotent. |
This issue is now closed. Please be mindful that future comments are hard for our team to see. If you need more assistance, please either tag a team member or open a new issue that references this one. If you wish to keep having a conversation with other community members under this issue feel free to do so. |
Use case
As a customer using the Idempotency utility I want my payloads to be considered idempotent regardless of the ordering of the keys/items within.
Currently, as discovered here, when we hash objects or arrays that have elements ordered differently they result in two different hashes. This causes the requests to be considered unique.
For reference, this is a simplified version of our hashing implementation:
Now, let's take two requests:
These two requests should be considered idempotent despite having the keys ordered differently, however in our current implementation, they are considered as two different requests:
We should implement a function that sorts the objects not only at the top level but also at nested levels.
Solution/User Experience
The change should be completely transparent for customers and the API/DX of the utility should not change.
In terms of implementation, the one found in this blog post could be a good starting point:
We could probably improve it when it comes to detecting objects & arrays using the utilities in the
commons
package as well as making it type safe.Alternative solutions
Acknowledgment
Future readers
Please react with 👍 and your use case to help us understand customer demand.
The text was updated successfully, but these errors were encountered: