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
payjoin::io::Error repeats the wrapped error's message in its source chain #2093
payjoin::io::Error shows a wrapped error twice in a source chain.
For a wrapped error (Reqwest, ParseUrl, Io, Rustls), Display prints the inner error's message, and source() returns that same inner error. Anything that walks the chain, such as anyhow's {:#}, prints the message twice:
error sending request for url (...): error sending request for url (...): connection refused
Plain {} avoids the repeat but drops the underlying cause, here "connection refused". So no formatting gives a complete message without the repeat.
This isn't a regression. The code has been this way since at least 9349c7e5 (May 2025). Callers today format these errors with {}, so nobody sees the repeat, but the underlying cause has always been missing from fetch errors.
An error should either include its inner error in Display or return it from source(), not both. The simplest fix is to give each wrapped variant its own short message, such as Self::Reqwest(_) => write!(f, "HTTP request failed"), and keep returning the inner error from source(). Callers that format with {:#} then get the full chain once.
OhttpEncapsulationError: Display and source() in payjoin/src/core/ohttp.rs. The Http, Ohttp, Bhttp and ParseUrl arms print the wrapped message with e.fmt(f) and also return Some(e) from source(). That's the pre-PR io bug.
Many more. A subagent checked every error type in the repo and found 54 variants across 21 types where the message includes the wrapped error's text and source() returns that same error. I opened four of them myself (ohttp.rs:79, send/error.rs:61, uri/v2.rs:271, core/error.rs:14), and the pattern is real in each.
They come in two forms:
Pure copy, the same form as finding 3. The message is just the wrapped error's text, so {:#} prints X: X.
Label plus copy. The message is label: {e}, so {:#} prints label: X: X. Option 3 avoids this because its source() skips a level. These variants return Some(e), so they repeat.
By file, with message line and source() line:
payjoin, pure copy
core/error.rs:14 / :18: ImplementationError. This is the wrapper for errors from users' own callbacks, so it's in many chains.
Borderline. Nine more variants put the wrapped error's Debug text in the message instead of its normal text (for example send/error.rs:49-50, uri/error.rs:108, 114). With {:#} the same error still appears twice, once in each format.
Two things stand out:
Repeats stack up across layers. Some outer types do skip a level correctly, but the duplicate further down still shows. For example, receive::Error::Protocol leads to PayloadError::Utf8, which still prints the Utf8 text twice.
The PR's change won't be visible to most users. Almost every user-facing error in payjoin repeats somewhere in its chain, so fixing only io.rs leaves anyone printing with {:#} still seeing repeats from the other 20 types.
Activity
xstoicunicornx commentedon Dec 3, 2026
Findings from claude opus 5.5:
Additional errors with the same issue
OhttpEncapsulationError: Display and source() inpayjoin/src/core/ohttp.rs. TheHttp,Ohttp,BhttpandParseUrlarms print the wrapped message withe.fmt(f)and also returnSome(e)fromsource(). That's the pre-PR io bug.HpkeError::Hpke: Display, line 290 and source(), line 310 inpayjoin/src/core/hpke.rs. Same pattern.Other errors like this
Many more. A subagent checked every error type in the repo and found 54 variants across 21 types where the message includes the wrapped error's text and
source()returns that same error. I opened four of them myself (ohttp.rs:79,send/error.rs:61,uri/v2.rs:271,core/error.rs:14), and the pattern is real in each.They come in two forms:
{:#}printsX: X.label: {e}, so{:#}printslabel: X: X. Option 3 avoids this because itssource()skips a level. These variants returnSome(e), so they repeat.By file, with message line and
source()line:payjoin, pure copy
core/error.rs:14/:18:ImplementationError. This is the wrapper for errors from users' own callbacks, so it's in many chains.core/hpke.rs:290/:310:HpkeError::Hpkecore/ohttp.rs:190-193/:203-206:OhttpEncapsulationError(4 variants)core/psbt/mod.rs:330/:345:InternalPsbtInputError::WeightErrorcore/psbt/mod.rs:372/:376:PsbtInputError(newtype)core/receive/error.rs:266-269/:292-295:PayloadError(Utf8,ParsePsbt,SenderParams,InconsistentPsbt)core/receive/v1/error.rs:43/:53:RequestError::InvalidContentLengthcore/send/error.rs:309/:289:ResponseError::WellKnownpayjoin, label plus copy
core/ohttp.rs:79/:96:DirectoryResponseError::OhttpDecapsulationcore/ohttp.rs:372-373/:384:OhttpKeysError::Decode,Encodecore/receive/error.rs:270/:296:PayloadError::InvalidInputUtxocore/receive/v2/error.rs:38-40/:50-52:SessionError(ParseUrl,Hpke,DirectoryResponse)core/receive/v2/error.rs:84-85/:97-98:CreateRequestError(Hpke,OhttpEncapsulation)core/send/error.rs:61-62/:84-85:BuildSenderError(AddressType,InputWeight)core/send/error.rs:130, 132/:145, 147:ValidationError(Proposal,V2Decapsulation)core/send/error.rs:195, 197, 198, 221/:231, 233, 234, 257:InternalProposalError(4 variants)core/send/error.rs:310/:290:ResponseError::Validationcore/send/v2/error.rs:28-29/:41-42:CreateRequestError(Hpke,OhttpEncapsulation)core/send/v2/error.rs:81-82/:92-93:DecapsulationError(Hpke,DirectoryResponse)core/uri/error.rs:49-50/:58-59:UriParseError(Bip21,PayjoinParams)core/uri/v2.rs:271-273/:283-285:PjParseError(3 variants)core/uri/v2.rs:304-305/:317-318:ParseOhttpKeysParamErrorcore/uri/v2.rs:339-340/:351-352:ParseExpParamErrorcore/uri/v2.rs:373-374/:386-387:ParseReceiverPubkeyParamErrordirectory.rs:54-55/:63-64:ShortIdErrorOther crates, all label plus copy
payjoin-cli/src/db/error.rs:31-36/:53-58:db::Error(4 variants)payjoin-ffi/src/error.rs:23/:24:SerdeJsonError(thiserror#[error("...: {0}")]with#[from])payjoin-mailroom/src/db/mod.rs:38-39/:51-52:db::Error(Operational,Timeout)payjoin-mailroom/src/db/files.rs:542/:529:files::Error::IOBorderline. Nine more variants put the wrapped error's
Debugtext in the message instead of its normal text (for examplesend/error.rs:49-50,uri/error.rs:108, 114). With{:#}the same error still appears twice, once in each format.Two things stand out:
receive::Error::Protocolleads toPayloadError::Utf8, which still prints the Utf8 text twice.io.rsleaves anyone printing with{:#}still seeing repeats from the other 20 types.Report wrapped io errors once in the source chain