Skip to content

Commit

Permalink
Ignore all aiohttp.ContentTypeError occurrences (#228)
Browse files Browse the repository at this point in the history
  • Loading branch information
No767 authored Nov 3, 2024
1 parent 80da90a commit c7ee771
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 5 deletions.
14 changes: 10 additions & 4 deletions bot/libs/utils/tree.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

from typing import TYPE_CHECKING

import aiohttp
import discord
from discord import app_commands

Expand Down Expand Up @@ -71,11 +72,16 @@ async def on_error(
interaction.command.qualified_name, # type: ignore
exc_info=original,
)
if interaction.response.is_done():
await interaction.followup.send(
embed=FullErrorEmbed(error), ephemeral=True
)

# Basically just ignore all content type errors for responses
# Since we already have them printed to stderr, it makes no sense to send a response back to the user when a response is already sent.
# In this case, it actually does more harm by giving the attackers more information than less.
if (
isinstance(original, aiohttp.ContentTypeError)
and original.status == 0
):
return

await interaction.response.send_message(
embed=FullErrorEmbed(error), ephemeral=True
)
Expand Down
2 changes: 1 addition & 1 deletion changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
- Use proper type checking imports (https://github.com/No767/Catherine-Chan/pull/216)
- Fix exception violations with pronouns tester (https://github.com/No767/Catherine-Chan/pull/212)
- Migrate from Bandit, Black, Autoflake and Isort to Ruff (https://github.com/No767/Catherine-Chan/pull/218, https://github.com/No767/Catherine-Chan/pull/223)
- Prevent unsanitized queries from creating Cloudflare errors (https://github.com/No767/Catherine-Chan/pull/226, https://github.com/No767/Catherine-Chan/pull/227)
- Prevent unsanitized queries from creating Cloudflare errors (https://github.com/No767/Catherine-Chan/pull/226, https://github.com/No767/Catherine-Chan/pull/227, https://github.com/No767/Catherine-Chan/pull/228)

## ✨ Additions

Expand Down

0 comments on commit c7ee771

Please sign in to comment.