serenity-rs / serenity

A Rust library for the Discord API.
https://discord.gg/serenity-rs
ISC License
4.68k stars 574 forks source link

Rust panics when fetching messages in a channel and one of the messages has a reaction. #2922

Closed yorunoken closed 1 month ago

yorunoken commented 1 month ago

example code:

let channel: GuildChannel = get_channel(); 

// Let's say there's a message with a reaction at the 30th message

let messages = channel.messages(&ctx.http, GetMessages::new().limit(10)).await.unwrap(); // Doesn't panic
let messages = channel.messages(&ctx.http, GetMessages::new().limit(20)).await.unwrap(); // Doesn't panic
let messages = channel.messages(&ctx.http, GetMessages::new().limit(29)).await.unwrap(); // Doesn't panic
let messages = channel.messages(&ctx.http, GetMessages::new().limit(30)).await.unwrap(); // Panics

here's the error:

called `Result::unwrap()` on an `Err` value: Json(Error("missing field `burst_colours`", line: 1, column: 3088))
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
jamesbt365 commented 1 month ago

Well it panics because you have unwrapped the value, unwrapping is not error handling.

Duplicate of #2910, #2909 and #2892. Please check before opening an issue in the future!