mirror of
https://github.com/hickory-dns/hickory-dns.git
synced 2026-04-25 03:05:51 +03:00
[GH-ISSUE #2895] Formatted ProtoErrorKind::Msg contains non-text #1079
Labels
No labels
blocked
breaking-change
bug
bug:critical
bug:tests
cleanup
compliance
compliance
compliance
crate:all
crate:client
crate:native-tls
crate:proto
crate:recursor
crate:resolver
crate:resolver
crate:rustls
crate:server
crate:util
dependencies
docs
duplicate
easy
easy
enhance
enhance
enhance
feature:dns-over-https
feature:dns-over-quic
feature:dns-over-tls
feature:dnsssec
feature:global_lb
feature:mdns
feature:tsig
features:edns
has workaround
ops
perf
platform:WASM
platform:android
platform:fuchsia
platform:linux
platform:macos
platform:windows
pull-request
question
test
tools
tools
trust
unclear
wontfix
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
starred/hickory-dns#1079
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @lilydjwg on GitHub (Mar 31, 2025).
Original GitHub issue: https://github.com/hickory-dns/hickory-dns/issues/2895
I sent a request over DoH and got 503 as response. I logged it since it wasn't successful, but systemd didn't like the log:
and console too:
I tried with
{:?},{:#}or{:#?}.This code seems to write the string directly without any escaping:
github.com/hickory-dns/hickory-dns@ba92a2a02a/crates/proto/src/error.rs (L176-L177)@djc commented on GitHub (Mar 31, 2025):
So this is from https://github.com/hickory-dns/hickory-dns/blob/main/crates/proto/src/h2/h2_client_stream.rs#L156.
That does use
String::from_utf8_lossy()which makes sure we end up with valid Unicode, but may insert mojibake in the case of binary content that's not actually textual content. I would expect that's pretty rare. I'm not sure this is really a problem, and even if it is, I'm not sure there's an obvious improvement.(I suppose we could yield an array of bytes as a structured logging element instead?)
@lilydjwg commented on GitHub (Apr 1, 2025):
Not only the replacement chars (which is fine), but also control chars (e.g. 0x7), which causes systemd to think is binary and breaks to multiple records (on each write?). There was a bell character in my case and it worked as a visual highlight. (Could someone intentionally inject some interesting ANSI escape sequences?)
I prefer bytes (e.g. as a list of u8). Or bstr if you can use it. Or at least do something to the control characters.
@marcus0x62 commented on GitHub (Apr 1, 2025):
Converting the error with String::from_utf8 with a fallback to a byte array would improve the error string by preserving the original bytes without always printing as a byte array (which would make the log substantially harder to read):
Then we could escape the resulting string to cover control characters (while preserving the byte values in case those are needed for troubleshooting:
But, escaping should probably be done system-wide if we're going to do it at all - most of the logging call sites include user- or network-provided request or response data as part of the log message.
@lilydjwg commented on GitHub (Apr 3, 2025):
Sounds reasonable, and I've opened https://github.com/tokio-rs/tracing/issues/3250.