mirror of
https://github.com/hickory-dns/hickory-dns.git
synced 2026-04-25 11:15:54 +03:00
[PR #2495] [MERGED] Use custom serde visitor to fix store error messages #3086
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#3086
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?
📋 Pull Request Information
Original PR: https://github.com/hickory-dns/hickory-dns/pull/2495
Author: @marcus0x62
Created: 10/7/2024
Status: ✅ Merged
Merged: 10/7/2024
Merged by: @marcus0x62
Base:
main← Head:fix_store_errors📝 Commits (2)
12eedb2Use custom serde visitor to fix store error messages2081900Merge branch 'main' into fix_store_errors📊 Changes
2 files changed (+132 additions, -43 deletions)
View changed files
📝
bin/src/hickory-dns.rs(+7 -16)📝
bin/src/lib.rs(+125 -27)📄 Description
Background
This change introduces a custom serde visitor to handle single-store and chained-store variants while still producing useful error messages. The chained authority PR used the serde untagged enum representation in order to represent single-store (TOML table, serde map) or chained-store (TOML array-of-tables, serde sequence) variants. Unfortunately, serde is not able to show useful error messages when a syntax error is encountered and untagged enums are being used. For example, misspelling the "type" option in a zone store configuration results in this error message to the user:
By using a minimal custom visitor, we can restore the previous, more useful error messages:
Single Store
Chained Stores
A side effect of this change is that StoreConfig is always represented as a Vec, which simplifies a bit of the code that iterates over the stores in bin/src/hickory-dns.rs.
Other Options
File a bug report with the serde team. This has been done by others, and it appears the serde maintainers have no intention of fixing this in serde proper, rejecting multiple PRs that address this issue. See, for example, here
Use one of the work-around crates published by the serde team.
Path to Error. This appears to work, but adds an additional crate to our dependency tree.
Serde Untagged. Has unacceptable type limitations (it only supports bool, i8, i16, i32, i64, i128, u8, u16, u32, u64, u128, f32, f64, char, string, borrowed_str, bytes, borrowed_bytes, byte_buf, unit, seq, map fields)
Make all stores an array-of-tables. In addition to breaking existing configurations, this seems counterintuitive to me.
Use a different configuration name for single- vs chained-stores: [zones.stores] for single stores and zones.chained_stores for chained stores. This still seems kind of clunky to me, particularly with the existing "stores" being plural for a single-store configuration, but is probably the next-best alternative.
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.