You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
directory should not leak operational errors to client #420
The problem is only that some of these instances should use the InternalServerError variant instead. lib.rs has 7 instances of the expression HandlerError::BadRequest(e.into()). I think the least error prone way way to address this is to go just blanket replace them all with e.into(), i.e. just remove the explicit tagging, and provide HandlerErrror with bunch of From impls for the necessary types. Dispatching based on what error it is on a type basis, not where it's generated as it's currently done, with the ? operator and explicit tagging of BadRequest vs. InternalServerError not being really distinguishable from a type checking point of view, since their single parameter is of the same type, that seems very easy to get wrong.
I'm not sure which of these prompted me to open this issue, can't recall, but here's one example to pick on:
afaict push_result can only result in operational errors, at this point the subdirectory id and the payload have already been validated. if the connection from the directory process to redis fails, for example, the client will get a bad request error even if it's request is prefectly valid.
There's already a From`` instance for hyper::http::Error. Another one for RedisResultthat is alwaysInternalServerError` seems obvious, not sure what else is missing but probably it's not much.
I think this issue is also a bit broader, for example:
It's not clear to me that this is always an internal server error, we might want to add gateway related errors if the failure is somehow semantically different. The laborious part of this issue is going through all instantiations of HandlerError with an explicit variant, working out what errors could end up getting wrapped like that, by following the nested ? and error conversions, and then thinking about who's fault that would be, kinda tedious.
this compiles, but i didn't really think through the From impls just, gotta draw the rest of the fucking owl as it were,. e -> HandlerError { e.into() } is probably also me being a rust n00b
Activity
[-]directory leaks operational errors to client[/-][+]directory should not leak operational errors to client[/+]nothingmuch commentedon Nov 29, 2024
in some cases i also saw a reset by peer instead of the error leaking, which is even worse as that borgs the error
DanGould commentedon Jan 20, 2025
Is this closed by #488, #456, ?
nothingmuch commentedon Jan 20, 2025
No, but those PR get us closer to fixing this.
The
BadRequestvariant ofHandlerErrorfortunately does not send the internalanyhow::Errorin the body, so this is not a serious/urgent problem:rust-payjoin/payjoin-directory/src/lib.rs
Lines 302 to 305 in 7d8116e
The problem is only that some of these instances should use the
InternalServerErrorvariant instead.lib.rshas 7 instances of the expressionHandlerError::BadRequest(e.into()). I think the least error prone way way to address this is to go just blanket replace them all withe.into(), i.e. just remove the explicit tagging, and provideHandlerErrrorwith bunch ofFromimpls for the necessary types. Dispatching based on what error it is on a type basis, not where it's generated as it's currently done, with the?operator and explicit tagging ofBadRequestvs.InternalServerErrornot being really distinguishable from a type checking point of view, since their single parameter is of the same type, that seems very easy to get wrong.I'm not sure which of these prompted me to open this issue, can't recall, but here's one example to pick on:
rust-payjoin/payjoin-directory/src/lib.rs
Lines 410 to 413 in 7d8116e
afaict
push_resultcan only result in operational errors, at this point the subdirectory id and the payload have already been validated. if the connection from the directory process to redis fails, for example, the client will get a bad request error even if it's request is prefectly valid.There's already a
From`` instance forhyper::http::Error. Another one forRedisResultthat is alwaysInternalServerError` seems obvious, not sure what else is missing but probably it's not much.I think this issue is also a bit broader, for example:
rust-payjoin/payjoin-directory/src/lib.rs
Lines 240 to 241 in 7d8116e
It's not clear to me that this is always an internal server error, we might want to add gateway related errors if the failure is somehow semantically different. The laborious part of this issue is going through all instantiations of HandlerError with an explicit variant, working out what errors could end up getting wrapped like that, by following the nested ? and error conversions, and then thinking about who's fault that would be, kinda tedious.
nothingmuch commentedon Jan 20, 2025
this compiles, but i didn't really think through the
Fromimpls just, gotta draw the rest of the fucking owl as it were,.e -> HandlerError { e.into() }is probably also me being a rust n00bDanGould commentedon Jan 20, 2025
You're looking for
.map_err(HandlerError::from)?Report mailroom storage errors as server errors