Repository navigation
DRIVERS-3656 test duplicate keys in BSON - #1991
Merged
Merged
Conversation
NoahStapp
requested changes
Oct 2, 2026
| builder.append("foo", 1) | ||
| builder.append("foo", 2) | ||
| got = builder.encode() | ||
| # Assert implementation-defined behavior. |
Contributor
There was a problem hiding this comment.
This isn't clear on expectation. We should specify that this means, depending on language, one of three results every time:
- Last value wins
- First value wins
- Error
If an implementation has inconsistent behavior, that does violate expectations.
Contributor
Author
There was a problem hiding this comment.
I like that idea. Updated as suggested. I added another possible expectation: "Both values preserved in-order". That is libbson's behavior.
|
|
||
| ```python | ||
| elements = list(bson.iter_elements(data)) | ||
| # Assert implementation-defined behavior. |
| # Bytes represent BSON for { 'foo': 1, 'foo': 2 } | ||
| data = bytes.fromhex("1700000010666f6f000100000010666f6f000200000000") | ||
| got = bson.encode(bson.decode(data)) | ||
| # Assert implementation-defined behavior. |
eramongodb
approved these changes
Oct 2, 2026
eramongodb
left a comment
Contributor
There was a problem hiding this comment.
Minor suggestions; otherwise, LGTM.
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.
Summary
Add prose tests to the BSON corpus for handling duplicate keys.
Details
No behavior changes are expected in BSON libraries. These tests are intended to verify driver documentation that will be required as part of DRIVERS-3656.
Prototype in the C driver: mongodb/mongo-c-driver#2461
Please complete the following before merging:
clusters).