A query cut short by its caller's context counts as a network error, so TestQueryNameserverIP_Timeout fails on some runs of next #298

Closed
opened 2026-10-15 18:33:29 +02:00 by clawbot · 1 comment
Collaborator

What is wrong. script/cibuild on next at 06ae357 failed in TestQueryNameserverIP_Timeout (internal/resolver/resolver_test.go:1398): expected status timeout, got error. The same test passed on the four next heads before it, and the commit in between changes no behaviour, so the test fails on some runs only.

Where. querySingleType (internal/resolver/iterative.go) records every error that is neither a timeout nor REFUSED as a network error. When the caller's context ends, queryDNS and tryExchange return ErrContextCanceled, which is not a reply or a fault of the nameserver, yet it lands there. Since #291, classifyResponse ranks a network error above a timeout, so a nameserver that only timed out is reported as network error: context canceled.

Scenario. The test gives the query a 3-second deadline at 192.0.2.1, where nothing answers. The first try of the first record type times out at 2 seconds; the deadline ends during the second. If the next record type starts before the context reports itself done, its query returns ErrContextCanceled, and the status becomes error. The test's own comment says it chose its deadline to avoid exactly this variation.

Correct. The queryEachType doc says a query the context cut short did not fail. Such a query gives no reason about the nameserver: it is not recorded as a network error, a timeout or anything else.

Done when: an error caused by the caller's context ending is not recorded as a reason in querySingleType; a nameserver whose only failures are timeouts, with its last query cut short by the context, gets timeout; a test that does not depend on timing covers this (for example querySingleType with a context already ended records nothing); TestQueryNameserverIP_Timeout stays as it is and passes.

Plan. Package internal/resolver; no new package. The change is in querySingleType. Live DNS only in any test that sends a query; a test with a context already ended sends none. TODO.md Completed Steps entry in the same commit.

Severity: major (next is red on some runs)

Model: opus-5-5

**What is wrong.** `script/cibuild` on `next` at `06ae357` failed in `TestQueryNameserverIP_Timeout` (`internal/resolver/resolver_test.go:1398`): expected status `timeout`, got `error`. The same test passed on the four `next` heads before it, and the commit in between changes no behaviour, so the test fails on some runs only. **Where.** `querySingleType` (`internal/resolver/iterative.go`) records every error that is neither a timeout nor REFUSED as a network error. When the caller's context ends, `queryDNS` and `tryExchange` return `ErrContextCanceled`, which is not a reply or a fault of the nameserver, yet it lands there. Since https://git.eeqj.de/sneak/dnswatcher/pulls/291, `classifyResponse` ranks a network error above a timeout, so a nameserver that only timed out is reported as `network error: context canceled`. **Scenario.** The test gives the query a 3-second deadline at `192.0.2.1`, where nothing answers. The first try of the first record type times out at 2 seconds; the deadline ends during the second. If the next record type starts before the context reports itself done, its query returns `ErrContextCanceled`, and the status becomes `error`. The test's own comment says it chose its deadline to avoid exactly this variation. **Correct.** The `queryEachType` doc says a query the context cut short did not fail. Such a query gives no reason about the nameserver: it is not recorded as a network error, a timeout or anything else. **Done when:** an error caused by the caller's context ending is not recorded as a reason in `querySingleType`; a nameserver whose only failures are timeouts, with its last query cut short by the context, gets `timeout`; a test that does not depend on timing covers this (for example `querySingleType` with a context already ended records nothing); `TestQueryNameserverIP_Timeout` stays as it is and passes. **Plan.** Package `internal/resolver`; no new package. The change is in `querySingleType`. Live DNS only in any test that sends a query; a test with a context already ended sends none. `TODO.md` Completed Steps entry in the same commit. Severity: major (`next` is red on some runs) Model: opus-5-5
clawbot self-assigned this 2026-10-15 18:33:29 +02:00
Author
Collaborator

#299: querySingleType records no reason for a query that ended with ErrContextCanceled, and a new test, which sends no query, checks that a nameserver whose earlier query timed out is still timeout after a query cut short by the context.

Model: opus-5-5

https://git.eeqj.de/sneak/dnswatcher/pulls/299: `querySingleType` records no reason for a query that ended with `ErrContextCanceled`, and a new test, which sends no query, checks that a nameserver whose earlier query timed out is still `timeout` after a query cut short by the context. Model: opus-5-5
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: sneak/dnswatcher#298