Skip to content

Wrong encoding guessed for Metabase API responses #1713

@sentry

Description

@sentry

Sentry Issue: BOT-130

The response doesn't include an encoding in the headers, so aiohttp has to guess. It sometimes guesses incorrectly, leading to decoding errors. The API does not document what the encoding of responses is. Would it be safe to assume it's always UTF-8?

UnicodeDecodeError: 'charmap' codec can't decode byte 0x81 in position 1009: character maps to <undefined>
  File "discord/ext/commands/core.py", line 85, in wrapped
    ret = await coro(*args, **kwargs)
  File "bot/exts/moderation/metabase.py", line 118, in metabase_extract
    out = await resp.text()
  File "aiohttp/client_reqrep.py", line 1081, in text
    return self._body.decode(encoding, errors=errors)  # type: ignore
  File "encodings/cp1254.py", line 15, in decode
    return codecs.charmap_decode(input,errors,decoding_table)

Error executing command invoked by Chrisjl#2655: !metabase extract 57

Metadata

Metadata

Assignees

No one assigned

    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