Skip to content

Some attachments being ignored in dm-log #1139

@wookie184

Description

@wookie184

Bug:

If you DM an attachment of a certain type (seems to only happen for smaller files or non image/video files, not exactly sure) to the bot, instead of relaying it to the dm-log channel as expected, the message is seemingly ignored.

Cause:

I did some detective work and found out this error was being raised by this function when the attachment was DMed to the bot:

bot_1       | 2020-08-31 17:46:29 | bot.utils.messages | WARNING | Failed to re-upload attachment test.txt from message 750048883488325682 with status 415.
bot_1       | Traceback (most recent call last):
bot_1       |   File "/bot/bot/utils/messages.py", line 79, in send_attachments
bot_1       |     await attachment.save(file, use_cached=True)
bot_1       |   File "/usr/local/lib/python3.8/site-packages/discord/message.py", line 124, in save
bot_1       |     data = await self.read(use_cached=use_cached)
bot_1       |   File "/usr/local/lib/python3.8/site-packages/discord/message.py", line 166, in read
bot_1       |     data = await self._http.get_from_cdn(url)
bot_1       |   File "/usr/local/lib/python3.8/site-packages/discord/http.py", line 239, in get_from_cdn
bot_1       |     raise HTTPException(resp, 'failed to get asset')
bot_1       | discord.errors.HTTPException: 415 Unsupported Media Type (error code: 0): failed to get asset

Some further investigations have lead me to believe that the problem is caused by using use_cached=True on this line, and indeed, looking at the docs for attachment.save it says Note that this can still fail to download deleted attachments if too much time has passed and it does not work on some types of attachments., which seems to fit.

Solution:

The simplest option would just be to removed use_cached (as it defaults to False). I'm not sure on the reasoning for setting it to True though, in the docs it says This will allow attachments to be saved after deletion more often, compared to the regular URL which is generally deleted right after the message is deleted, although I'm not sure how necessary this is.

I would be happy to make whatever change is necessary for this, if somebody can confirm what I am observing is correct and the solution is correct. Let me know here or on discord if you are struggling to reproduce this, thanks.

Metadata

Metadata

Assignees

Labels

a: moderationRelated to community moderation functionality: (moderation, defcon, verification)p: 2 - normalNormal Priorityt: bugSomething isn't working

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions