[gateway] Reject duplicate MAP keys in entry arrays - #4205
Open
Gezi-lzq wants to merge 1 commit into
Open
Conversation
Reject duplicate decoded keys before encoding canonical MAP entry arrays so later values cannot silently overwrite earlier entries.
naivedogger
approved these changes
Sep 3, 2026
naivedogger
left a comment
Contributor
There was a problem hiding this comment.
+1. Thanks for catching this. Comparing keys after schema-aware decoding is the right approach, since it also catches equivalent JSON representations such as 7 and "7". The implementation and tests look good to me. cc @beryllw
beryllw
approved these changes
Sep 3, 2026
beryllw
left a comment
Contributor
There was a problem hiding this comment.
LGTM! Thanks for the fix.
2 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Purpose
Linked issue: close #4204
Canonical MAP entry arrays currently accept duplicate decoded keys. When such a row is read, a later value can silently overwrite an earlier value. This change rejects the invalid MAP at the Gateway REST boundary.
Brief change log
v[index].keypath as an invalid value.7and"7").Tests
cargo test --all-targetscargo fmt --all -- --checkcargo clippy --all-targets -- -D warnings -A clippy::needless_borrows_for_generic_args -A clippy::uninlined_format_argsgit diff --checkAPI and Format
No public API or storage format changes. Invalid canonical MAP entry arrays with duplicate keys now return HTTP 400 instead of being written.
Documentation
No documentation changes. This fixes validation of an existing API contract.