Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug Report: upload_file receives NotAuthenticated error #92

Open
NotAussie opened this issue Jan 21, 2025 · 0 comments
Open

Bug Report: upload_file receives NotAuthenticated error #92

NotAussie opened this issue Jan 21, 2025 · 0 comments
Labels
unconfirmed bug Something isn't working

Comments

@NotAussie
Copy link

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 <[email protected]>
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)
@NotAussie NotAussie added the unconfirmed bug Something isn't working label Jan 21, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
unconfirmed bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant