fix(dns): treat empty DNS response as an error - #7741
Open
aivus wants to merge 2 commits into
Open
Conversation
When a hostname exists but has no records of the requested type (e.g. a host with only a CNAME/A record queried for AAAA), Node's resolver resolves with an empty array instead of throwing ENODATA. This produced a confusing empty "Records:" heartbeat message and a DOWN status with no useful information. Throw a descriptive error when the response is an empty array so the monitor reports a meaningful failure. Fixes louislam#4979
Contributor
|
Thanks for the PR! If anyone would like to help with testing, run: |
9 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
In this pull request, the following changes are made:
DnsMonitorType.dnsResolve()now throws a descriptive error when the DNS resolver returns an empty array, instead of passing it downstream.Background: when a hostname exists but has no records of the requested type (e.g. a host that only has a
CNAME/Arecord queried forAAAA), Node'sResolver.resolve()resolves with an empty array rather than throwingENODATA(documented behaviour: nodejs/node#21795). Previously this surfaced as a DOWN monitor with a confusing emptyRecords:message. The monitor now reportsNo AAAA records found for <hostname>(or the relevant record type/hostname).The
Array.isArrayguard leaves object-returning types likeSOAunaffected, andPTR(reverse lookup) is handled before this check.Please follow this checklist to avoid unnecessary back and forth (click to expand)
Testing
Added
test/backend-test/monitors/test-dns.jscovering both the empty-response (throws) and non-empty-response (returns records) cases, usingnode:testmocks so it does not depend on the network:🤖 Generated with Claude Code
Re-creation of #7598 due to the fact that PR is stuck on GH side