fix: preserve supported questions when unknown types are present - #508
Twister915 wants to merge 1 commit into
Conversation
|
I had my agent spit out some options for this. I'm using this comment as a scratchpad to hold some design options / ideas. This particular suggestion seems... a little heavy handed, adding a new envelope struct to contain the diagnostics. Let me know your thoughts about the tradeoff between keeping track of these diagnostics vs tracing silent failure like I proposed originally. I feel like the current behavior, total failure, is 100% correct but at the cost of being a little impractical to use. Below this line is AI After looking more closely at the parser and public API, I think the concern about silent recovery is fair. Here is a possible direction for revising this. Separate unsupported questions from malformed packetsA well-formed question with an unfamiliar numeric QTYPE is still parseable. We can decode its name, type, and class even if the responder cannot answer it. I would prefer to retain that information internally and let the responder handle the supported questions, while reporting which ones it could not handle. Invalid names, truncated fields, or other cases where parsing cannot safely continue should remain errors. Retaining unknown questions also preserves the original question section for legacy-unicast replies. Simply skipping them loses that information. I would use a private raw-question representation or private Return structured recovery information internallyConceptually, the internal parser could return: Result<ParsedPacket, ParseError>
// Sketch, not a proposed public API:
struct ParsedPacket {
message: DnsIncoming,
diagnostics: Vec<ParseDiagnostic>,
}For example, an
Expose diagnostics without surprising existing clientsMy preference is an additive, opt-in method such as A smaller alternative is a new There is also a distinction between API compatibility and behavior: accepting the supported part of a formerly rejected packet is an intentional behavior change. I would document it as the recovery fix. If preserving the old rejection policy is required, an explicit opt-in recovery policy can retain strict handling as the default, though existing clients would then need to opt in to get the fix. Tests to add before revisingThe current patch also needs to address I would test typed diagnostics alongside successful A/AAAA handling, unknown-only packets, preservation of the original question section, malformed input remaining fatal, the chosen strict/recovery policy, and slow or absent diagnostic subscribers. That would make the recovery behavior observable and deliberate while keeping the existing public API usable. |
Hello! I am submitting three fixes to bugs I encountered while developing a tvOS app for myself.
The app failed to discover my Rust service once again, and the root cause was determined to be an issue with dealing with an "unsupported question type" which my app was emitting. This patch allows you to process other requests which are supported.
Reading the patch... I realize this just turns an error into a silent failure. I could argue that this may be OK behavior, but only within the context of my application. I imagine other applications may want to handle this sort of partial failure differently. I am happy to discuss other possible designs and implement whatever we think makes the most sense. This, however, is an improvement over total failure as well, I'd say.
Here is the PR description that my agent wrote (gpt-6 astra):
A well-formed DNS packet containing one unsupported question type currently fails parsing as a whole. For example, an HTTPS (type 65) question bundled with AAAA and A causes the valid address questions to be discarded too.
Once the question's name, type, and class have been consumed and validated, skip an unsupported type and continue parsing the packet. Malformed or truncated questions still fail validation. This also preserves resource records after the question section.
The wire-format regressions cover types 64, 65, and a future type (65400) at the beginning, middle, and end of a mixed question section, followed by a known answer. They also cover an unknown-only question and truncated question fields. The supported-question checks remain valid if type 64/65 support is added separately; this PR does not need new enum variants.
Validation
cargo fmt --check, async-only build, and all-feature documentation with warnings denied pass.test_hostname_resolution_address_removedandtest_interface_flipfailed. The first also fails on untouched upstream75d1941; the second passes when run alone on both this branch and the untouched base.This is one independent commit on current upstream
main; no other PR is required.