Preserve truncated replies during no-data delegation
perfloop-oss/coredns · Value Kind Confusion
https://perfloop.ai/t/oss/case_89tymxs8cz
Verdict
VERIFIED · settled 2026-11-15 · pull request opened as coredns/coredns#8772
What happened: The check fails before this change and passes with it.
Hypothesis
An empty truncated DNS reply can be replaced by a different resolver's answer when no-data delegation is enabled. The client then loses the truncation flag that would let it retry the selected resolver over TCP. This is an opt-in configuration; its deployment frequency and user impact are unmeasured.
Forward.ServeDNS retries truncated responses internally only when prefer_udp is enabled and force_tcp is not set, at lines 209-213. Otherwise the response reaches lines 282-286, where NOERROR plus isEmpty(ret) triggers the next forwarder without checking ret.Truncated. Answer emptiness therefore serves as a discriminator between completed no-data replies and incomplete replies, although both can be empty. The issue also merits checking for the empty truncated responses deliberately synthesized by plugin/pkg/proxy/connect.go:214-223, whose comment says the purpose is to make the client retry over TCP. The README documents next_on_nodata at line 142 and the separate transport policy at lines 73-77.
A new native test file, plugin/forward/perfloop_replykind_check_test.go, supplied TestPerfloopForwardTruncatedEmptyReplay. The exact command `go test ./plugin/forward -run '^TestPerfloopForwardTruncatedEmptyReplay$' -count=1 -timeout=30s -v` failed with `iteration=0 upstream_udp=1 upstream_tcp=0 next=1 other=0 TC=false answers=1; want udp=1 tcp=0 next=0 other=0 TC=true answers=0`. It used parsed forward blocks, max_fails 0, one UDP A query, no prefer_udp or force_tcp, an empty NOERROR reply with TC set, and a next forwarder returning one answer. ServeDNS returned 0,nil. The request and response IDs were preserved. This one-query replay is the supported counterexample; the accompanying 192-configuration search stopped on a fixture cleanup error and provides no completed-search claim.
The smallest useful Case check is that replay against the intended completeness semantics, followed by complete empty-answer controls and transport fallback controls. Establish the property across the no-data handoff, including final truncated replies and proxy-synthesized truncation, without broadening the separately explicit next RCODE policy. The checker layout is provisional. Native regression coverage is required by .github/CONTRIBUTING.md:22-25. The existing attempt-budget, mixed-error traversal, response-write, and active-cancellation repairs do not change this discriminator. User user:4 withdrew hyp_x8my20x81n for uncommon opt-in configuration, bounded extra work and no measured harm; that prioritization applies to that cap hypothesis, not evidence that truncation loss is harmless. The same actor's rejected-publication closures for cancellation and cache cloning supply no contrary runtime evidence here.
Open https://github.com/coredns/coredns/pull/8648 adds next_on_nodata to the syntax example only. The inspected implementation hunks in https://github.com/coredns/coredns/pull/8667 add metrics, https://github.com/coredns/coredns/pull/8132 snapshot dynamically resolved upstreams, https://github.com/coredns/coredns/pull/7047 add an ECS retry, and https://github.com/coredns/coredns/pull/6804 change connection retention; none adds this completeness distinction. The open-PR listing was followed to its last page. Local owner history is shallow, and bounded REST history reads were refused with HTTP 403. The named mailing-list archive search at https://groups.google.com/g/coredns-discuss/search?q=next_on_nodata%20truncated was also refused with HTTP 403; older and off-host overlap remain evidence gaps.
Change to test: Require a complete reply before applying next_on_nodata, so an unresolved truncated response retains its client retry signal. Preserve explicit response-code delegation and the configured prefer_udp and force_tcp behavior.
Where it lives
Evidence
The check fails before this change and passes with it: `With next_on_nodata enabled, Forward.ServeDNS preserves a final empty NOERROR reply with TC set, including proxy-synthesized UDP truncation, unless an explicit next RCODE policy delegates it; configured UDP/TCP retry and complete no-data handoff behavior remain intact.`
Checks: 2 of 2 passed. Verification: no defect found.
Timeline
2026-11-15· Case opened2026-11-15· PR opened