Codable haven an issue while unwraping back value from document.
If I have an object with wariable
`var salt: [UInt8] = [0,1,2,3,4,5,68,122,254,255]
on getting back object with this error is returned
Initializing from document failed: dataCorrupted(Swift.DecodingError.Context(codingPath: [], debugDescription: "BSON number <0> does not fit in UInt8", underlyingError: nil))
Could not initialize User from document
What I've notice the range in Codable.swift is wrong.
That's true not only for UInt8 but others as well.
My example Model:
final class User: Model {
var _id = ObjectId()
var salt: [UInt8] //Temporary solution - store salt as hexString
var password: String
var login: String
}
Codable haven an issue while unwraping back value from document.
If I have an object with wariable `var salt: [UInt8] = [0,1,2,3,4,5,68,122,254,255]
on getting back object with this error is returned
What I've notice the range in
Codable.swift
is wrong.instead of unwraping full range back into Uint8
0,1,2…253,254,255
This https://github.com/OpenKitten/BSON/blob/0a0dd33ebe9b25c5c8ee488fe86dbb4c4fa48dd2/Sources/BSON/Codable.swift#L626 Constraints range to this0 {1,2…253,254} 255
throwing an error when ever 0 or 255 appear.That's true not only for
UInt8
but others as well.My example Model: