reactiveui/refit · error · InvalidOperationException
{missing.Count} expected request(s) were not made:{Environme
Error message
{missing.Count} expected request(s) were not made:{Environment.NewLine}{string.Join(Environment.NewLine, missing)} What it means
Thrown by StubHttp.ThrowIfOutstanding (invoked at validation/disposal) when one or more non-reusable, non-fallback routes were registered as expected but never hit by a request. It enforces that every one-shot expectation you set up actually occurred, surfacing a list of the unmet routes.
Source
Thrown at src/Refit.Testing/StubHttp.cs:536
{
for (var i = 0; i < _routes.Count; i++)
{
var route = _routes[i];
if (route.Reusable || route.Fallback || _consumed[i])
{
continue;
}
missing.Add($" - {route.Method?.Method ?? "ANY"} {route.Template}");
}
}
if (missing.Count == 0)
{
return;
}
throw new InvalidOperationException(
$"{missing.Count} expected request(s) were not made:{Environment.NewLine}{string.Join(Environment.NewLine, missing)}");
}
/// <summary>Marks a non-reusable route consumed and signals completion once the last one is hit.</summary>
/// <param name="index">The index of the route that satisfied a request.</param>
/// <remarks>
/// Excluded from coverage: the double-consume guard only triggers when two requests race the same
/// one-shot route between matching and consumption, which cannot be exercised deterministically.
/// </remarks>
[ExcludeFromCodeCoverage]
private void Consume(int index)
{
lock (_gate)
{
if (_consumed[index])
{
return;
}View on GitHub (pinned to b455f65ecc)
Solutions
- Make the SUT perform the expected call, or remove expectations for calls you don't actually require.
- If the call is optional, register it as reusable (so it never counts against outstanding expectations).
- Inspect the listed missing routes and reconcile with the actual requests captured in stub.Requests to find the URI/method mismatch.
Example fix
// before — expected but never called stub.Expect(HttpMethod.Delete, "api/items/5").Respond(204); await client.GetAsync(5); // forgot to delete stub.Verify(); // throws: 1 expected request(s) not made // after — perform the expected call, or mark reusable await client.DeleteAsync(5); stub.Verify();
Defensive patterns
Strategy: validation
Validate before calling
// Prefer asserting the calls you actually expect; reuse routes for optional calls.
// Before verifying, cross-check registered one-shot routes against stub.Requests.
foreach (var r in stub.RegisteredRoutes)
{
// ensure your SUT performs each expected call, or remove the expectation
} Prevention
- Only register one-shot expectations for calls the SUT must make; mark optional ones reusable.
- Call stub.Verify()/dispose in the test to surface unmet expectations immediately, near the cause.
- Compare the missing-routes list against stub.Requests to find URI/method mismatches.
When it happens
Trigger: You registered an expectation (a one-shot route) but the system under test never made that request (or made it to a different URI/method). At verification time the stub iterates routes and collects any non-reusable/non-fallback route whose _consumed flag is still false, then throws with the list.
Common situations: Over-specifying expectations (asserting a call path the SUT didn't take); the SUT short-circuited via caching/validation; an exception earlier in the test prevented the call; the route URI didn't quite match so a fallback absorbed it instead.
Related errors
- No request has been received yet.
- No stubbed route matched the request: {request.Method} {requ
- The HttpResponseMessage has no associated RequestMessage. Wh
AI-assisted analysis of reactiveui/refit@b455f65ecc (2026-08-13).
Data as JSON: /api/errors/92349acf8b7a8324.
Report an issue: GitHub.