-
Type:
Bug
-
Resolution: Unresolved
-
Priority:
Unknown
-
None
-
Affects Version/s: bson-6.10.0
Use Case
As a... BSON user
I want... EJSON.serialize to convert Uint8Arrays to the same representation as BSON.Binary
So that... Uint8Array's handling aligns with other types in EJSON and BSON
// Example with regexp > BSON.EJSON.parse(BSON.EJSON.stringify(/asdfa/)) new BSONRegExp('asdfa', '') // Handling of BSON.Binary > BSON.EJSON.parse(BSON.EJSON.stringify(new BSON.Binary([1,2,3,4,5]))) Binary.createFromBase64('AQIDBAU=', 0) // Current handling of Uint8Array > BSON.EJSON.parse(BSON.EJSON.stringify(new Uint8Array([1,2,3,4,5]))) { '0': 1, '1': 2, '2': 3, '3': 4, '4': 5 }
User Experience
- Correct EJSON serialization/stringification of Uint8Array
- Not sure how much this impacts users, was found here
Dependencies
- Not blocking for logging, but will make the changes in this PR more accurate
Risks/Unknowns
- This would be a bug fix, but would we consider it breaking?
Acceptance Criteria
Implementation Requirements
- Update EJSON.serialize and EJSON.stringify to ensure that it handles Uint8Array instances by wrapping them with a BSON.Binary instance
Testing Requirements
- Add unit tests to verify that EJSON.serialize(Uint8Array) returns a BSON.Binary
- Add unit tests to verify that EJSON.stringify(Unit8Array) returns the same string as EJSON.stringify() of a BSON.Binary representing the same data
Documentation Requirements
- None
Follow Up Requirements
- color: Color value is invalid
None