Skip to content

Fix MongoDB Document::toString() to produce valid JSON#5183

Merged
matejk merged 1 commit intomainfrom
mongodb-to-string-fixes
Feb 6, 2026
Merged

Fix MongoDB Document::toString() to produce valid JSON#5183
matejk merged 1 commit intomainfrom
mongodb-to-string-fixes

Conversation

@matejk
Copy link
Copy Markdown
Contributor

@matejk matejk commented Feb 6, 2026

Summary

  • Quote string-like BSON values (Binary, ObjectId, RegularExpression, JavaScriptCode) in Document::toString() output so it produces valid JSON
  • Previously, values like UUID(...), Base64 binary data, ObjectId hex strings, regex patterns, and JavaScript code were emitted unquoted, resulting in invalid JSON
  • Add toString assertions to existing BSON tests to verify proper quoting

Test plan

  • All 84 MongoDB tests pass (MongoDB-testrunner -all)
  • Verified Binary (Base64 and UUID), ObjectId, RegularExpression, and JavaScriptCode produce quoted values
  • Verified full Document::toString() output with these types is valid JSON

@matejk matejk added this to the Release 1.15.0 milestone Feb 6, 2026
@matejk matejk merged commit d5549af into main Feb 6, 2026
100 checks passed
@matejk matejk deleted the mongodb-to-string-fixes branch February 6, 2026 11:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant