All contributions

App-vNext/Polly

Polly

A .NET library for handling transient faults: retries, circuit breakers, timeouts and fallback. Its Simmy module injects faults on purpose to test how an application copes with them.

Language
C#
GitHub stars
14,255
Merged changes
1
Project site
thepollyproject.org

What we changed

FaultGenerator returns null when there is no fault to inject, instead of throwing InvalidOperationException and failing a call the strategy was meant to leave alone. The fix shipped in version 8.8.0.

What this work shows

  • Nullable value types and structs in C#
  • Chaos testing with Simmy
  • xUnit unit tests
What was broken

An empty fault generator failed the call

A FaultGenerator with no exceptions registered, or with all weights at zero, threw InvalidOperationException ("Nullable object must have a value"). The null-forgiving operator (!) does nothing at runtime, so .Value on an empty Nullable failed a call that ChaosFaultStrategy was meant to leave alone.

How we fixed it

No fault means null

The delegate now passes the result through ?.Exception, as the sibling OutcomeGenerator does. When there is no fault it returns null and the strategy lets the call through untouched, which two new tests check.

#3220

Merged change

1 6 September 2026

What it taught us

We catch bugs the compiler lets through: the null-forgiving operator (!) in C# does not guard against an empty Nullable at runtime. We back such a fix with tests that fail on the old code and pass on the new one.

More about this technology: C# and .NET

Other projects we write code for

Describe your project.

A free quote comes back within an hour during working hours.