[PR #2181] [MERGED] error: wrap io::Error in Arc for clone #2863

Closed
opened 2026-03-16 11:12:15 +03:00 by kerem · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/hickory-dns/hickory-dns/pull/2181
Author: @cpu
Created: 4/13/2024
Status: Merged
Merged: 4/14/2024
Merged by: @djc

Base: mainHead: cpu-io-err-clone


📝 Commits (1)

  • c6473dd error: wrap io::Error in Arc for clone

📊 Changes

1 file changed (+4 additions, -7 deletions)

View changed files

📝 crates/proto/src/error.rs (+4 -7)

📄 Description

ProtoErrorKind is Clone, but the Io variant holding io::Error runs into trouble with this: since the io::Error error can't be cloned we have to reconstruct it and this is a lossy proces resulting in a "simple" io::Error that only holds the error type from the parent it was cloned from. This loses important details like the underlying error source/message.

This branch changes ProtoErrorKind::Io to hold Arc<io::Error> instead (Note: this is a breaking change). This makes implementing Clone trivial - we clone the arc - and no error information is lost.

With this fix in place we get a much better error fidelity from failures like trying to perform DNS-over-HTTPS using Rustls but without a source of trust anchors (e.g. https://github.com/hickory-dns/hickory-dns/issues/2066). Previously the error was surfaced as:

failed to lookup HTTPS record type: ResolveError { kind: Proto(ProtoError { kind: Io(Kind(InvalidData)) }) }'

With this change in place, the error is now surfaced with much more detail:

failed to lookup HTTPS record type: ResolveError { kind: Proto(ProtoError { kind: Io(Custom { kind: InvalidData, error: InvalidCertificate(UnknownIssuer) }) }) }

Updates https://github.com/hickory-dns/hickory-dns/issues/2066


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/hickory-dns/hickory-dns/pull/2181 **Author:** [@cpu](https://github.com/cpu) **Created:** 4/13/2024 **Status:** ✅ Merged **Merged:** 4/14/2024 **Merged by:** [@djc](https://github.com/djc) **Base:** `main` ← **Head:** `cpu-io-err-clone` --- ### 📝 Commits (1) - [`c6473dd`](https://github.com/hickory-dns/hickory-dns/commit/c6473ddcbaaeee4e1d8e12d258b782448cdd0d65) error: wrap io::Error in Arc for clone ### 📊 Changes **1 file changed** (+4 additions, -7 deletions) <details> <summary>View changed files</summary> 📝 `crates/proto/src/error.rs` (+4 -7) </details> ### 📄 Description `ProtoErrorKind` is `Clone`, but the `Io` variant holding `io::Error` runs into trouble with this: since the `io::Error` error can't be cloned we have to reconstruct it and this is a lossy proces resulting in a "simple" `io::Error` that only holds the error type from the parent it was cloned from. This loses important details like the underlying error source/message. This branch changes `ProtoErrorKind::Io` to hold `Arc<io::Error>` instead (**Note: this is a breaking change**). This makes implementing `Clone` trivial - we clone the arc - and no error information is lost. With this fix in place we get a much better error fidelity from failures like trying to perform DNS-over-HTTPS using Rustls but without a source of trust anchors (e.g. https://github.com/hickory-dns/hickory-dns/issues/2066). Previously the error was surfaced as: ``` failed to lookup HTTPS record type: ResolveError { kind: Proto(ProtoError { kind: Io(Kind(InvalidData)) }) }' ``` With this change in place, the error is now surfaced with much more detail: ``` failed to lookup HTTPS record type: ResolveError { kind: Proto(ProtoError { kind: Io(Custom { kind: InvalidData, error: InvalidCertificate(UnknownIssuer) }) }) } ``` Updates https://github.com/hickory-dns/hickory-dns/issues/2066 --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
kerem 2026-03-16 11:12:15 +03:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/hickory-dns#2863
No description provided.