Bad JSON: value is outside of safe range
ferologics opened this issue · comments
Problem
When sending a [video] message to the room via Matrix iOS SDK client to https://server_endpoint/_matrix/client/r0/rooms/!roomId:host/send/m.room.message/messageId
with following request body:
{"body":"video_5e1f43c.mp4","info":{"duration":30466.666666666664,"thumbnail_url":"mxc:\/\/localhost\/e76b28e344ae8c388cc19e42fb7eb73d397b1931001a0fd62f26f199d1b3cd1a","mimetype":"video\/mp4","w":480,"h":270,"thumbnail_info":{"size":0,"mimetype":"image\/jpeg","w":0,"h":0}},"url":"mxc:\/\/localhost\/55e9366d7a68d7970b8071145d631745d36231a4f2eeccab366a61f8ef521626","msgtype":"m.video"}
we get an unexpected error:
{
"errcode": "M_BAD_JSON",
"error": "gomatrixserverlib: bad JSON: value is outside of safe range"
}
This suggests that the request body is invalid JSON -- at least according to the Canonical JSON Appendix.
I went ahead and verified the JSON grammar according to RFC7159 standard via https://jsonformatter.curiousconcept.com which successfully validated the JSON
I decided to validate the JSON error myself with a custom go script which converts the request body JSON to byte array and validates it against gomatrixserverlib CanonicalJSON() and EnforcedCanonicalJSON().
This showed that the JSON is invalid in the case of the Room Version
6.
To my understanding this should't happen?
Desktop (please complete the following information):
- macOS 11.3 Beta (20E5186d)
- dendrite version
Smartphone (please complete the following information):
- Device: iPhone XsMax
- OS: iOS 14.2.2
Additional context
Go script for validating the failing request body can be found here
The error is correct and should happen, floats aren't allowed in canonical JSON.
Yes! Thanks 👍 closing this in favor of matrix-org/matrix-ios-sdk#1070