h3poteto / megalodon-rs

Fediverse API client library for Rust
Apache License 2.0
106 stars 24 forks source link

Mastodon account parsing error when followers_count is negative #221

Closed lmorchard closed 3 months ago

lmorchard commented 3 months ago

Was fetching statuses from my Mastodon account with get_account_statuses and ran into this error:

Error: error decoding response body: invalid value: integer `-1`, expected u32 at line 1 column 29610

Caused by:
    invalid value: integer `-1`, expected u32 at line 1 column 29610

Tracked it down to a -1 value for followers_count in an account in one of my boosts:

➜  megalodon-rs git:(lmorchard-negative-followers) curl 'https://hackers.town/api/v1/accounts/136533/statuses?limit=5&max_id=112231250495631688' | jq | grep followers_count
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100 20252  100 20252    0     0  77286      0 --:--:-- --:--:-- --:--:-- 77297
      "followers_count": 2491,
      "followers_count": 2491,
      "followers_count": 2491,
        "followers_count": -1,
      "followers_count": 2491,
      "followers_count": 2491,

I wouldn't be surprised if this is a caching bug in Mastodon, but it causes parsing failure over in this library.