Skip to content

Return null from FaultGenerator when no fault is generated - #42

Merged
iancooper merged 1 commit into
mainfrom
port/482bdf82-faultgenerator-null
Sep 27, 2026
Merged

iancooper merged 1 commit into
mainfrom
port/482bdf82-faultgenerator-null

Conversation

@iancooper

Copy link
Copy Markdown
Member

Port of App-vNext/Polly@482bdf82 (upstream App-vNext/Polly#3220), from upstream sync #1. Refs #28.

What

The implicit conversion from FaultGenerator to Func<FaultGeneratorArguments, ValueTask<Exception?>> dereferenced the generated outcome unconditionally. A generator with no exceptions registered, or with every weight at zero, therefore threw InvalidOperationException: Nullable object must have a value instead of returning null (no fault).

  • src/Paramore.Fences.Core/Simmy/Fault/FaultGenerator.cs: !.Value.Exception becomes ?.Exception. This is upstream's one-line fix.
  • FaultGeneratorTests: upstream's two tests, renamed to Member_Scenario_Outcome as ImplicitConversion_NoExceptionRegistered_ReturnsNull and ImplicitConversion_AllWeightsZero_ReturnsNull. Both fail without the fix.

Checks

  • No public API change (ADR 0003 D7), so .PublicAPI/ is untouched. No dependency changes.
  • Analyser-clean build. Core tests pass on net10.0, net9.0 and net8.0.
  • CHANGELOG.md is untouched. It is generated from PR titles at release time, so this PR's title is the entry.
  • Locally, coverlet intermittently reports 99.96% line coverage (ComponentDisposeHelper.cs:30). Unmodified main does the same, so this isn't caused by this change. See Coverage collection is unreliable, and blocks the coverlet 10 upgrade #14.

🤖 Generated with Claude Code

…o fault is generated

The implicit conversion from FaultGenerator to the FaultGenerator delegate
dereferenced the generated outcome unconditionally, so a generator with no
exceptions registered, or with every weight at zero, threw
InvalidOperationException instead of returning null (no fault).

Upstream: App-vNext/Polly#3220. Refs #28.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
@iancooper iancooper added bug Something isn't working .NET Pull requests that update .NET code labels Sep 27, 2026
@iancooper
iancooper merged commit ca743e7 into main Sep 27, 2026
21 of 23 checks passed
@iancooper
iancooper deleted the port/482bdf82-faultgenerator-null branch September 27, 2026 10:19
@github-actions github-actions Bot locked and limited conversation to collaborators Sep 27, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

bug Something isn't working .NET Pull requests that update .NET code

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant