Skip to content

Bug Report: upload_file receives NotAuthenticated error #92

Open
@NotAussie

Description

@NotAussie

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)

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions