Skip to content

Conversation

@nbbeeken
Copy link
Contributor

@nbbeeken nbbeeken commented Jan 4, 2026

Description

Summary of Changes

  • the Binary constructor now casts to a number and truncates the value to fit in a byte
  • Improved error message in toUUID to echo the type information of the sub_type
Notes for Reviewers

Even with the ctor fix I still changed the error message bc the sub_type is writable.

What is the motivation for this change?

Improved error message for debugging and improved construction for consistency with serializer.

Release Highlight

new Binary(buffer, subType) now coerces subType to match BSON bytes

The Binary constructor now normalizes subtype inputs to match BSON serialization. Previously, passing a stringified subtype like '4' would cause a mismatch between the sub_type property (string '4') and the serialized BSON value (0x04). The constructor now converts inputs to ensure consistency.

Double check the following

  • Lint is passing (npm run check:lint)
  • Self-review completed using the steps outlined here
  • PR title follows the correct format: type(NODE-xxxx)[!]: description
    • Example: feat(NODE-1234)!: rewriting everything in coffeescript
  • Changes are covered by tests
  • New TODOs have a related JIRA ticket

@nbbeeken nbbeeken requested a review from a team as a code owner January 4, 2026 16:46
@dariakp dariakp added tracked-in-jira There is a ticket in Mongo's Jira instance tracking this issue/PR wip labels Jan 5, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

tracked-in-jira There is a ticket in Mongo's Jira instance tracking this issue/PR wip

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants