Skip to content

Commit

Permalink
Fix snowflake deserializer
Browse files Browse the repository at this point in the history
Fixes snowflake deserializers (ChannelId, UserId, etc.) by switching
from a usage of `deserialize_u64` to `deserialize_any`.

Our usage of `deserialize_u64` was incorrect and the erroneous behaviour
was fixed in serde_json v1.0.8. We were essentially telling serde that
the received type was a u64, when in fact it can be multiple types
(strings, u64, or an i64 just in case).

This resulted in errors like:

```
Client error: Json(ErrorImpl { code: Message("invalid type: string
\"317727377985634305\", expected identifier"), line: 1, column: 100 })
```

Due to this, simple operations such as even connecting a client failed.
  • Loading branch information
Zeyla Hellyer committed Dec 9, 2017
1 parent f218fd4 commit 77f462e
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/model/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ macro_rules! id_u64 {
self
}
}

impl From<u64> for $name {
fn from(id_as_u64: u64) -> $name {
$name(id_as_u64)
Expand All @@ -94,7 +94,7 @@ macro_rules! id_u64 {

impl<'de> Deserialize<'de> for $name {
fn deserialize<D: Deserializer<'de>>(deserializer: D) -> StdResult<Self, D::Error> {
deserializer.deserialize_u64(U64Visitor).map($name)
deserializer.deserialize_any(U64Visitor).map($name)
}
}
)*
Expand Down

0 comments on commit 77f462e

Please sign in to comment.