Describe the bug
When a streamer goes live, the Discord bot looks up their Twitch profile for the embed thumbnail. If that Helix call fails (503, timeout, 429), the error is ignored and userInfo.ProfileImageURL is read from a nil pointer, which panics and kills the process:
|
annoContent := s.GetStreamAnnoContent(ctx, service, guildId, streamerData.UserID) |
|
formattedString := helper.FormatContent(annoContent, streamerData) |
|
userInfo, err := s.twitchService.GetUserInfoByLoginName(streamerData.UserLogin) |
|
if err != nil { |
|
// TODO |
|
} |
|
dS.ChannelMessageSendComplex(gs.DiscordChannelID, &discordgo.MessageSend{Content: formattedString, Embeds: []*discordgo.MessageEmbed{ |
|
{ |
|
Title: fmt.Sprintf("%s - Twitch", streamerData.UserName), |
|
Description: streamerData.Title, |
|
URL: fmt.Sprintf("https://twitch.tv/%s", streamerData.UserLogin), |
|
Thumbnail: &discordgo.MessageEmbedThumbnail{URL: userInfo.ProfileImageURL}, |
|
}, |
To Reproduce
Make GetUserInfoByLoginName return an error during handleAnnouncement (reproduced with a fake TwitchService): invalid memory address or nil pointer dereference.
Expected behavior
The announcement is sent without a thumbnail (or skipped and retried), and the bot keeps running.
Describe the bug
When a streamer goes live, the Discord bot looks up their Twitch profile for the embed thumbnail. If that Helix call fails (503, timeout, 429), the error is ignored and
userInfo.ProfileImageURLis read from a nil pointer, which panics and kills the process:monorepo/apps/discord-bot/internal/service/streamer/streamer.go
Lines 366 to 378 in 35a83bd
To Reproduce
Make
GetUserInfoByLoginNamereturn an error duringhandleAnnouncement(reproduced with a fake TwitchService):invalid memory address or nil pointer dereference.Expected behavior
The announcement is sent without a thumbnail (or skipped and retried), and the bot keeps running.