Skip to content

[CI] Flaky: MessageHandlerTest.AcceptSslCertificatesServicePointManager — httpbin.org premature response termination #25873

Description

@rolfbjarne

Flaky Test Report (automated)

Test: MonoTests.System.Net.Http.MessageHandlerTest.AcceptSslCertificatesServicePointManager(System.Net.Http.HttpClientHandler)
Platform: macOS (Debug, static registrar)
Category: Flaky (external network dependency)
Period: June 29–30, 2026

Occurrence Summary

PR Build Configuration Bot Attempt Direct Link
#25858 14517509 monotouch-test/macOS/Debug (static registrar) AcesShared 90 1 Run tests
#25858 14517509 monotouch-test/macOS/Debug (static registrar) AcesShared 8 2 Run tests (attempt 2)

Total: Failed consistently on both attempts (different bots), confirming it's not bot-specific.

Error Details

MonoTests.System.Net.Http.MessageHandlerTest.AcceptSslCertificatesServicePointManager(System.Net.Http.HttpClientHandler):
  Assert.That(ex, Is.Null)
  Expected: null
  But was: <System.Net.Http.HttpRequestException: Error while copying content to a stream.
    ---> System.Net.Http.HttpIOException: The response ended prematurely. (ResponseEnded)
    at System.Net.Http.HttpConnection.FillAsync(Boolean async)
    at System.Net.Http.HttpConnection.CopyToContentLengthAsync(...)
    at System.Net.Http.HttpConnection.ContentLengthReadStream.CompleteCopyToAsync(...)
    at System.Net.Http.HttpConnectionResponseContent.<SerializeToStreamAsync>g__Impl|6_0(...)
    at System.Net.Http.HttpContent.LoadIntoBufferAsyncCore(...)

Root Cause Analysis

The test makes HTTP requests to httpbin.org (an external service) using HttpClientHandler:

  • Calls httpbin.org/redirect/3 (follows 3 redirects)
  • The external server drops the TCP connection mid-response
  • HttpIOException: The response ended prematurely (ResponseEnded) is thrown

Why it's not caught as inconclusive:

The test calls TestRuntime.IgnoreInCIIfBadNetwork(ex) (tests/common/TestRuntime.cs:1618), which handles:

  • HTTP status codes (502, 504, 503)
  • Network connection lost (SocketException)
  • DNS resolution failures
  • Timeouts

But it does NOT handle HttpIOException / "response ended prematurely". This is a gap — premature response termination is clearly a network issue that should mark the test Inconclusive in CI.

Suggested Fix

Add a check for HttpIOException in IgnoreInCIIfBadNetwork:

// In TestRuntime.cs, add to IgnoreInCIIfBadNetwork(Exception? ex):
IgnoreInCIIfResponseEndedPrematurely (ex);

// New helper:
public static void IgnoreInCIIfResponseEndedPrematurely (Exception ex)
{
    var httpIoEx = FindInner<System.Net.Http.HttpIOException> (ex);
    if (httpIoEx is null)
        return;
    if (!IsRunningOnCI)
        return;
    Assert.Inconclusive ($"Ignoring network issue in CI: {httpIoEx.Message}");
}

Related Issues

Classification

This failure is unrelated to PR #25858 (which improves macOS test runner diagnostic output). It's caused by the external dependency on httpbin.org, which intermittently drops TCP connections.


This issue was automatically generated by CI post-mortem analysis.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugIf an issue is a bug or a pull request a bug fixci-failureThe issue only affects CIci-postmortemCI post-mortem analysis: flaky tests, infrastructure failures, shared regressionscopilot

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions