Bug Report: upload_file receives NotAuthenticated error #46

Open
opened 2026-02-15 23:16:23 -05:00 by yindo · 1 comment
Owner

Originally created by @NotAussie on GitHub (Jan 21, 2025).

Describe the bug

The .upload_file() function fails to authenticate and raises KeyError.

Also this issue would of been easier to diagnose if revolt.http.upload_file had proper HTTP error handling or used response.raise_for_status after its main checks to prevent rouge/unexpected errors.

To Reproduce

The command below reliably produces the error.

@commands.command()
async def image_test(self, ctx: commands.Context):

  with open("image.png", "rb") as f:
    file = await ctx.client.upload_file(revolt.File(f.read()), "attachments")

    await ctx.message.reply(file.id)

Expected behavior

The file to be uploaded without an authentication error.

Library version

Name: revolt.py
Version: 0.2.0
Summary: Python wrapper for the revolt.chat API
Home-page: https://github.com/revoltchat/revolt.py
Author:
Author-email: Zomatree <me@zomatree.live>
License:
Location: d:\projects\github\spacey\.venv\lib\site-packages
Requires: aenum, aiohttp, typing-extensions, ulid-py

Additional context

Traceback:

Traceback (most recent call last):
  File "D:\Projects\GitHub\Spacey\.venv\lib\site-packages\revolt\ext\commands\command.py", line 105, in invoke
    return await self.callback(self.cog or context.client, context, *args, **kwargs)
  File "D:\Projects\GitHub\Spacey\modules\misc.py", line 38, in image_test
    file = await ctx.client.upload_file(revolt.File(f.read()), "attachments")
  File "D:\Projects\GitHub\Spacey\.venv\lib\site-packages\revolt\client.py", line 473, in upload_file
    ulid.id = asset["id"]
KeyError: 'id'

HTTP Response:

{"type": "NotAuthenticated", "location": "crates/core/database/src/models/users/axum.rs:21:17"}

System information:

  • OS: Windows 10 (Version 22H, OS build 19045.4780)
Originally created by @NotAussie on GitHub (Jan 21, 2025). **Describe the bug** The `.upload_file()` function fails to authenticate and raises `KeyError`. > Also this issue would of been easier to diagnose if `revolt.http.upload_file` had proper HTTP error handling or used `response.raise_for_status` after its main checks to prevent rouge/unexpected errors. **To Reproduce** The command below reliably produces the error. ```python @commands.command() async def image_test(self, ctx: commands.Context): with open("image.png", "rb") as f: file = await ctx.client.upload_file(revolt.File(f.read()), "attachments") await ctx.message.reply(file.id) ``` **Expected behavior** The file to be uploaded without an authentication error. **Library version** ``` Name: revolt.py Version: 0.2.0 Summary: Python wrapper for the revolt.chat API Home-page: https://github.com/revoltchat/revolt.py Author: Author-email: Zomatree <me@zomatree.live> License: Location: d:\projects\github\spacey\.venv\lib\site-packages Requires: aenum, aiohttp, typing-extensions, ulid-py ``` **Additional context** _Traceback:_ ```python Traceback (most recent call last): File "D:\Projects\GitHub\Spacey\.venv\lib\site-packages\revolt\ext\commands\command.py", line 105, in invoke return await self.callback(self.cog or context.client, context, *args, **kwargs) File "D:\Projects\GitHub\Spacey\modules\misc.py", line 38, in image_test file = await ctx.client.upload_file(revolt.File(f.read()), "attachments") File "D:\Projects\GitHub\Spacey\.venv\lib\site-packages\revolt\client.py", line 473, in upload_file ulid.id = asset["id"] KeyError: 'id' ``` _HTTP Response:_ ```json {"type": "NotAuthenticated", "location": "crates/core/database/src/models/users/axum.rs:21:17"} ``` _System information:_ - OS: Windows 10 (Version 22H, OS build 19045.4780)
yindo added the unconfirmed bug label 2026-02-15 23:16:23 -05:00
Author
Owner

@greeeen-dev commented on GitHub (Feb 13, 2025):

Just opened a PR for this: #93

@greeeen-dev commented on GitHub (Feb 13, 2025): Just opened a PR for this: #93
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: stoatchat/python-client-sdk#46