Skip to content

Conversation

caseyclements
Copy link
Contributor

We have chosen not to require drivers to throw an error if data coming out of the server has non-zero ignored bits. This is for backwards-compatibility. The changes are the result of conversations with Dev Tools. The situation we want to avoid is that a non-technical user cannot get their data out. Imagine the situations of a user of Compass, who tries to look at her data, and gets nothing but exceptions. Instead, we require new writes to zero our data on writes, but allow freedom for drivers to migrate to the end goal of always requiring ignored bits to be zero according to their particular versioning and whether or not they've already implemented this feature.

Completed:

  • Update changelog.
  • Test changes in at least one language driver (python)
  • Test these changes against all server versions and topologies (including standalone, replica set, and sharded
    clusters).

@caseyclements caseyclements requested a review from kevinAlbs June 27, 2025 19:49
Copy link
Contributor

@kevinAlbs kevinAlbs left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM with minor comments addressed.

Prose tests were run in the C driver here (excluding comparison, since the bson_vector_packed_bit_view_t does not support comparison).

assert v2 != v1 # Also chosen to be unequal at BinaryVector level as [255] != [128]
```

Drivers MAY skip this test if they choose not to implement a `Vector` type.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
Drivers MAY skip this test if they choose not to implement a `Vector` type.
Drivers MAY skip this test if they choose not to implement a `Vector` type, or the type does not support comparison.

Suggest permitting drivers skip this test if the Vector type does not support comparison. The C driver bson_vector_packed_bit_view_t (which I expect is the closest analog to the Vector type) does not support comparison.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tracked in #1819.

assert b1 == Binary(b'\x10\x07\x80', subtype=9) # This is effectively a roundtrip.
v1 = Binary.as_vector(b1)

b2 = Binary.from_vector([0b11111111], BinaryVectorDtype.PACKED_BIT, padding=7)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I expect Binary.from_vector would raise an exception for non-zero ignored bits. Suggest instead directly doing:

b1 = Binary(b'\x10\x07\x80', subtype=9)
b2 = Binary(b'\x10\x07\xff', subtype=9)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tracked in #1819.

Copy link
Contributor

@nbbeeken nbbeeken left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, however possibly another driver maintainer is worth looping in (up to you @caseyclements)

@caseyclements caseyclements merged commit 6689929 into mongodb:master Jun 30, 2025
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants