Skip to content

fix(resolver): keep the upstreams' errors in the strict strategy - #2441

Open
Devehab wants to merge 1 commit into
0xERR0R:mainfrom
Devehab:fix/strict-keep-upstream-error
Open

Devehab wants to merge 1 commit into
0xERR0R:mainfrom
Devehab:fix/strict-keep-upstream-error

Conversation

@Devehab

@Devehab Devehab commented Dec 1, 2026

Copy link
Copy Markdown
Contributor

Fixes #2436.

With strategy: strict, StrictResolver dropped every upstream's error and returned its own once none of them answered. Over UDP, TCP and DoT an upstream's SERVFAIL comes back as an UpstreamServerError, so it never made it to Server.resolve. The client got blocky's own SERVFAIL without the upstream's extended DNS error, and each such query logged error on processing request.

Now the errors are joined into the one it returns, the same way ParallelBestResolver does it. Server.resolve finds the UpstreamServerError and answers with the upstream's message. Failover to the next upstream works the same as before.

If several upstreams answer SERVFAIL, the client gets the first one's, since errors.AsType walks the joined errors in order. With strict that's the preferred upstream, which seemed like the right one to show.

Tests (in strict_resolver_test.go, the upstream mock answers SERVFAIL with an EDE so the test can tell its message from one blocky made):

  • the only upstream answers SERVFAIL: the error holds that message, EDE included
  • the first answers SERVFAIL and the second times out: still the first one's message
  • the first answers SERVFAIL and the second answers: the second's answer is used, as before

The first two fail without the change. go vet ./resolver/ and the strict specs pass. I didn't add a server-level test, since Server.resolve already handles the UpstreamServerError that parallel_best returns.

StrictResolver dropped the error of every upstream and returned its own
when none answered. Over UDP, TCP and DoT an upstream's SERVFAIL comes
as an UpstreamServerError, so with `strategy: strict` it never reached
the server: the client got a SERVFAIL without the upstream's extended
DNS error, and every such query logged an ERROR.

The errors are now joined into the returned one, as ParallelBestResolver
does, so the server finds the UpstreamServerError and answers with the
upstream's message. Failing over to the next upstream is unchanged.

Fixes 0xERR0R#2436
@codecov

codecov Bot commented Dec 1, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 92.67%. Comparing base (520f598) to head (80b2b9d).
⚠️ Report is 3 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #2441      +/-   ##
==========================================
- Coverage   92.68%   92.67%   -0.01%     
==========================================
  Files         137      137              
  Lines        9923     9926       +3     
==========================================
+ Hits         9197     9199       +2     
- Misses        725      726       +1     
  Partials        1        1              

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

upstreams.strategy: strict answers with its own error when the upstream answered SERVFAIL

1 participant