kord-extensions icon indicating copy to clipboard operation
kord-extensions copied to clipboard

ext-pluralkit: If the `Manage Webhook` permission is missing, the exception should be caught or handled

Open NoComment1105 opened this issue 3 years ago • 3 comments
trafficstars

Description

After integrating the ext-pluralkit module into our bot recently, our logs are now littered with hundreds of KtorRequestExceptions due to the Manage Webhook permissions missing in some servers.

Reproduction

Send a message with the ext-pluralkit being used and Manage Webhooks disallowed for the bot

The ideal fix would be catching these, logging under debug or trace, or sending a message in the guild the error is from (probably best but TOS breaking)

NoComment1105 avatar Sep 12 '22 18:09 NoComment1105

I was hoping you'd have actually provided one of these exceptions?

gdude2002 avatar Sep 25 '22 09:09 gdude2002

It's easily reproducible, I figured you'd be capable.

NoComment1105 avatar Sep 25 '22 11:09 NoComment1105

25-09-2022 16:20:36 | DefaultDispatcher-worker-5     | WARN  | c.k.k.e.m.extra.pluralkit.PKExtension    | Failed to retrieve webhooks for channel: 1005873630774841417
dev.kord.rest.request.KtorRequestException: REST request returned an error: 403 Forbidden  Missing Permissions null
	at dev.kord.rest.request.KtorRequestHandler.handle(KtorRequestHandler.kt:61)
	at dev.kord.rest.request.KtorRequestHandler$handle$1.invokeSuspend(KtorRequestHandler.kt)
	at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:33)
	at io.ktor.util.pipeline.SuspendFunctionGun.resumeRootWith(SuspendFunctionGun.kt:138)
	at io.ktor.util.pipeline.SuspendFunctionGun.loop(SuspendFunctionGun.kt:112)
	at io.ktor.util.pipeline.SuspendFunctionGun.access$loop(SuspendFunctionGun.kt:14)
	at io.ktor.util.pipeline.SuspendFunctionGun$continuation$1.resumeWith(SuspendFunctionGun.kt:62)
	at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:46)
	at io.ktor.util.pipeline.SuspendFunctionGun.resumeRootWith(SuspendFunctionGun.kt:138)
	at io.ktor.util.pipeline.SuspendFunctionGun.loop(SuspendFunctionGun.kt:112)
	at io.ktor.util.pipeline.SuspendFunctionGun.access$loop(SuspendFunctionGun.kt:14)
	at io.ktor.util.pipeline.SuspendFunctionGun$continuation$1.resumeWith(SuspendFunctionGun.kt:62)
	at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:46)
	at io.ktor.util.pipeline.SuspendFunctionGun.resumeRootWith(SuspendFunctionGun.kt:138)
	at io.ktor.util.pipeline.SuspendFunctionGun.loop(SuspendFunctionGun.kt:112)
	at io.ktor.util.pipeline.SuspendFunctionGun.access$loop(SuspendFunctionGun.kt:14)
	at io.ktor.util.pipeline.SuspendFunctionGun$continuation$1.resumeWith(SuspendFunctionGun.kt:62)
	at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:46)
	at io.ktor.util.pipeline.SuspendFunctionGun.resumeRootWith(SuspendFunctionGun.kt:138)
	at io.ktor.util.pipeline.SuspendFunctionGun.loop(SuspendFunctionGun.kt:112)
	at io.ktor.util.pipeline.SuspendFunctionGun.access$loop(SuspendFunctionGun.kt:14)
	at io.ktor.util.pipeline.SuspendFunctionGun$continuation$1.resumeWith(SuspendFunctionGun.kt:62)
	at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:46)
	at io.ktor.util.pipeline.SuspendFunctionGun.resumeRootWith(SuspendFunctionGun.kt:138)
	at io.ktor.util.pipeline.SuspendFunctionGun.loop(SuspendFunctionGun.kt:112)
	at io.ktor.util.pipeline.SuspendFunctionGun.access$loop(SuspendFunctionGun.kt:14)
	at io.ktor.util.pipeline.SuspendFunctionGun$continuation$1.resumeWith(SuspendFunctionGun.kt:62)
	at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:46)
	at kotlinx.coroutines.DispatchedTask.run(DispatchedTask.kt:106)
	at kotlinx.coroutines.scheduling.CoroutineScheduler.runSafely(CoroutineScheduler.kt:570)
	at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.executeTask(CoroutineScheduler.kt:750)
	at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.runWorker(CoroutineScheduler.kt:677)
	at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.run(CoroutineScheduler.kt:664)
(times 2, with an id for the pk message)

Here is your exception information. As previously detailed, send a message with PK, when the bot does not have the manage webhooks permission

NoComment1105 avatar Sep 25 '22 15:09 NoComment1105

Going through issues and cleaning up - I'm not sure if you realised this at the time, but that log shows that the exception is caught and handled!

gdude2002 avatar Feb 28 '24 10:02 gdude2002