#responding to a slash command with attachment=hikari.URL(<invalid url>) causes some issues

1 messages · Page 1 of 1 (latest)

eternal hearth
#

when doing the following:

await ctx.respond('None', attachment=hikari.URL('https://sdfgfksfgjskfhjgksdfhjgksdgsdfgsd.com'))```out of an arc slash command it causes an `AttributeError: '_RequestContextManager' object has no attribute '_resp'` while i'd expect it to controllably raise something like a `hikari.BadRequestError` and it can be caught with a try-except but it causes an asyncio error to be shown in the console regardless if it was caught or not which is not a good sign

I don't know if this is a bug but having to test your URLs beforehand manually seems wrong if there's a `aiohttp.client_exceptions.ClientConnectorError` raised on the way to the attribute error ("during handling of the above [aiohttp] exception...") which does gives you the result that 'the url is bad' for you, it just seems that there's a bug in the exception handler (?)
warm oar
#

forget that, i am on massive autopilot rn

#

@eternal hearth ill have a look at the hikari one, but for you, you should look at ```py
File "C:\Users\TheCreatorrrr\AppData\Local\Programs\Python\Python311\Lib\socket.py", line 962, in getaddrinfo
for res in _socket.getaddrinfo(host, port, family, type, proto, flags):
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
socket.gaierror: [Errno 11001] getaddrinfo failed

#

thats your real error

#

btw, this would normally raise aiohttp.client_exceptions.ClientConnectorError

eternal hearth
# warm oar thats your real error

i'm not sure what i can do about that error since it seems to originate from hikari or arc, the socket.gaierror is no longer there for my code to intervene

warm oar
#

nono, i spooted it wrong

#

the one that will be raise to you (after i fixed this greatly spotted bug btw) should be the aiohttp.client_exceptions.ClientConnectorError you see in the traceback

#
pip install git+https://github.com/davfsa/hikari@bugfix/incorrect-web-reader-closure

if you want to test it out

#

lmk if everything is sorted :)

eternal hearth
# warm oar lmk if everything is sorted :)

uhh there seems to be another issue, now there's a BadRequestError when i try to respond to the interaction again, also there's another (very simillar) BadRequestError on shutdown now: hikari.errors.BadRequestError: Bad Request 400: (40060) 'Interaction has already been acknowledged.' for https://discord.com/api/v10/interactions/......(blah blah blah)
I tried:

try:
  await ctx.respond(attachment=hikari.URL('https://sdfgfksfgjskfhjgksdfhjgksdgsdfgsd.com'))
except Exception as e: 
  c(f'caught {tcr.extract_error(e)}')
  # if i try to respond here a BadRequestError is raised.```
There seems to be a `hikari.HTTPError` which i can catch now (nothing wrong here)
But there are to be two `hikari.BadRequestError`s now after the retrying for `ClientConnectorError` ends unsuccessfully

The '❌ Something went wrong contact the bot developer' seems to be given out immediately once first ClientConnectorError is raised (as opposted to what i'd think should happen: keep retrying until out of retries, only then tell thet user of an error)

What i think is happening is that the ctx.respond is trying to create an initial response but due to the previously triggered '❌ Something went wrong...' it can't, i'm only wondering why is it that ❌ gets triggered, the `ClientConnectorError` seems to be handled?
#

(the purple print is where i call c())

warm oar
#

The '❌ Something went wrong contact the bot developer' seems to be given out immediately once first ClientConnectorError is raised (as opposted to what i'd think should happen: keep retrying until out of retries, only then tell thet user of an error)

I assume the "Something went wrong contact the bot developer" is an arc thing, and just from logic, they should not be able to handle anything, so its impossible that they are seeing the ClientConnectorError. It does make me think that its due to you not having enough time to respond (just from the backoffs alone, you are exceeding 3s, which you need to respond as specified by Discord)

What i think is happening is that the ctx.respond is trying to create an initial response but due to the previously triggered '❌ Something went wrong...' it can't, i'm only wondering why is it that ❌ gets triggered, the ClientConnectorError seems to be handled?
@winged dirge thats you. I havent looked into it, but its your lib :P

#

and the final error is also something for hyper to look at (seems to do with the autodefer)

winged dirge
#

if you get a "Something went wrong" that means an exception occured inside the command callback that you did not handle

#

it either wasn't caught

#

or you have no error handler handling it

#

you can disable this behaviour by making an empty error handler on the client

#

overriding this default behaviour

warm oar
#

doesnt arc log the error when that happens?

winged dirge
#

it does

warm oar
#

then were in logs 🤔

winged dirge
warm oar
#

wait, no way discord did this

#

please dont tell me they did nvm, thought they changed the error for responding too late

eternal hearth
winged dirge
#

this is the impl

#

I just dump the traceback in stderr

#

just like python does

warm oar
#

you should be using that

#

not a print

winged dirge
#

that's not what python tracebacks do

warm oar
#

you can add the traceback too :P

winged dirge
#

I try to make it work like how python works

warm oar
#

@winged dirge adding the exec_info will make it work like python would

winged dirge
#

noted

warm oar
#

anyways

winged dirge
#

but either way

#

it should not get lost

warm oar
#

back to the thing at hand

#

where error

winged dirge
#

unless you redirected stderr

#

and it is printed before the response is made

#

also the response silently fails if it cannot happen, as you can see

#

so it has no way to fuck up the traceback not being printed

#

the only thing that can potentially happen is that the response deadlocks the bot or smth, but then that would happen after the traceback is already printed

warm oar
#

@eternal hearth would you be able to provide the full code you used?

winged dirge
#

yeah if you can give me a minimally reproducible example then I can take a look

winged dirge
# winged dirge

and also if you have an error handler that doesn't re-raise an error itself, it should just pass the exc to that

#

and not use the default impl

eternal hearth
warm oar
#

just a random thing

winged dirge
#

I have to say, this is quite cursed

#

you should just use hooks to check these (dev_only_cmd) instead

eternal hearth
warm oar
#

why eval catThink

#

we just replace parts of the banner with colour markers depending on whether colours are enabled or not

eternal hearth
#

the banner file is:
{color1}sometext{color2}someothertext

warm oar
#

there are ways to replace it without using eval

eternal hearth
warm oar
eternal hearth
warm oar
#

ill let hyper help you with this, idk what is wrong :)

eternal hearth
winged dirge
#

.remind 30m

unique finch
#

I love the hikari banner file, its beautiful. it looks italic lmao

warm oar
#

lmao

unique finch
#

hikari

shadow badgeBOT
#

@winged dirge: Reminder!

No Message.

Original Message

[Jump](#1254066636290396221 message)

winged dirge
#

that's odd, lol

#

what happens if you remove the try/catch

#

and just try to respond

eternal hearth
winged dirge
#

odd

#

but you do get the traceback eventually

#

just.. later

eternal hearth
#

like, i am getting the traceback later just because on shutdown an asyncio task notices it was never retrieved

#

it looks like the bad request itself is done when the command exits

#

wait what

#

why would it do anything if command finished successfully (all errors would've been caught by the bare except in this case there)

warm oar
#

that exception is raised by the autodefer

#

its doing something weird

#

@winged dirge

winged dirge
eternal hearth
winged dirge
#

but autodefer should not happen if you do ctx.respond beforehand

warm oar
#

what arc version do you have?

winged dirge
#

also a good question

warm oar
#

but this is weird already

winged dirge
#

like I use a lock on ctx.respond to ensure autodefer cannot hijack a response in progress

#

or vice-versa

eternal hearth
winged dirge
#

can you narrow this down to a minimally reproducible example

#

like a bot with 1 command

#

that still has this issue

#

I'll take a look on my end & see what arc is doing

eternal hearth
#

sure

eternal hearth
#

okay, it looks like i fixed it (i think the issue was on my side), thanks for help