Skip to content

Relax address-family check in DnsGetHostEntry_LocalhostSubdomain_RespectsAddressFamily on Android/AppleMobile#128404

Draft
Copilot wants to merge 2 commits into
mainfrom
copilot/ci-scan-test-failure-fix
Draft

Relax address-family check in DnsGetHostEntry_LocalhostSubdomain_RespectsAddressFamily on Android/AppleMobile#128404
Copilot wants to merge 2 commits into
mainfrom
copilot/ci-scan-test-failure-fix

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented May 20, 2026

On android-arm64, DnsGetHostEntry_LocalhostSubdomain_RespectsAddressFamily(InterNetwork) flakes because the Android OS resolver returns link-local IPv6 entries (e.g. fe80::…%47) alongside the requested IPv4 results for test.localhost, so Assert.All over AddressList fails on the wrong-family entries.

Changes:

  • In src/libraries/System.Net.NameResolution/tests/FunctionalTests/GetHostEntryTest.cs, on Android and Apple mobile, require only that the requested family is represented (Assert.Contains) and skip the per-address Assert.All check. Strict validation is preserved on all other platforms.
  • Mirrors the existing Android/AppleMobile relaxation pattern used by DnsGetHostEntry_LocalhostAndSubdomain_BothReturnLoopback in the same file.
  • Factored the sync/async assertions into a local VerifyAddressFamily helper to avoid duplication.
bool strictAddressFamily = !PlatformDetection.IsAppleMobile && !PlatformDetection.IsAndroid;

IPHostEntry entry = Dns.GetHostEntry(hostName, addressFamily);
VerifyAddressFamily(entry, addressFamily, strictAddressFamily);

entry = await Dns.GetHostEntryAsync(hostName, addressFamily);
VerifyAddressFamily(entry, addressFamily, strictAddressFamily);

static void VerifyAddressFamily(IPHostEntry entry, AddressFamily addressFamily, bool strictAddressFamily)
{
    Assert.Contains(entry.AddressList, addr => addr.AddressFamily == addressFamily);
    if (strictAddressFamily)
    {
        Assert.All(entry.AddressList, addr => Assert.Equal(addressFamily, addr.AddressFamily));
    }
}

…roid/AppleMobile

Co-authored-by: kotlarmilos <11523312+kotlarmilos@users.noreply.github.com>
Copilot AI requested review from Copilot and removed request for Copilot May 20, 2026 13:33
Copilot AI changed the title [WIP] Fix test failure for DnsGetHostEntry_LocalhostSubdomain_RespectsAddressFamily Relax address-family check in DnsGetHostEntry_LocalhostSubdomain_RespectsAddressFamily on Android/AppleMobile May 20, 2026
Copilot AI requested a review from kotlarmilos May 20, 2026 13:34
@dotnet-policy-service
Copy link
Copy Markdown
Contributor

Tagging subscribers to this area: @karelz, @dotnet/ncl
See info in area-owners.md if you want to be subscribed.

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[ci-scan] Test failure: System.Net.NameResolution.Tests.GetHostEntryTest.DnsGetHostEntry_LocalhostSubdomain_RespectsAddressFamily

2 participants