Flaky on windows-latest: OAuth metadata fetch times out in in-memory tests (same class as #1701, not covered by #1702)

Open
#1,806 3 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
3/5
Estimated time
1-2 days
Newbie friendliness
68/100
Issue type
Bug
Clarity
Mostly clear
Activity status
Active
Tech stack
csharp

Research direction

Read GetAuthServerMetadataAsync and compare its timeout handling with the server/discover probe timeout added by #1702. Reproduce the failure by rerunning the windows-latest Build and Test leg, starting with the three named tests. Done means metadata-fetch timeouts surface as timeout errors rather than assertion failures, and the affected tests are deterministic.

Written by the indexing model from the issue text.

Description

area-tests bug help wanted P3 ready for work

Describe the bug

Several OAuth tests occasionally fail on the windows-latest legs of Build and Test.
If that occurs, the GetAuthServerMetadataAsync method gets a TaskCancelledException
during a slow TLS handshake using the in-memory duplex pipe, ClientOAuthProvider wraps
that into the "Failed to find .well-known/..." message, and assertion expectations
about that message fail on the injected text – that is, the error manifests itself as
a confusing assertion failure instead of a timeout.

It appears to be similar to #1701 from the OAuth side of things. #1702 increased
the server/discover probe timeout in the in-memory tests, but the OAuth metadata
path has a similar timeout which was not added and is still failing after that merge.

Tests affected so far:

  • OAuth.AuthTests.CannotAuthenticate_WithInvalidClientMetadataDocument
  • OAuth.DcrFailureTests.DcrRejection_PropagatesToConsumer_WithStatusBodyAndSentParameters
  • ClientConformanceTests.RunConformanceTest(scenario: "auth/offline-access-scope")

To Reproduce
Intermittent, not deterministic reproduction possible. It is reproduced by running Build and Tests
of windows-latest leg multiple times.

The following two incidents are on August 9, right after merging PR #1702, for two consecutive
commits of the same branch which are identical but different in comments and tests:

  1. a9f02522 - windows-latest, Debug - job - auth/offline-access-scope
  2. e07f4999 - windows-latest, Release - [job](https://

Expected behavior
Tests need to be deterministic. In case the timeout happens during fetching of the metadata, the issue should be thrown as a timeout and not as an assertion failure on an error message that’s not related to it at all.

Logs
From the e07f4999 Release run

Dominant language
C#
Stars
4.5k
Forks
814
Avg merge
9d 19h
Merged PRs (30d)
4

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from modelcontextprotocol/csharp-sdk

All issues in modelcontextprotocol/csharp-sdk

Similar issues

More C# issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.