Repository navigation
MF White List: DependencyInjection package and retry filter - #355
Merged
Merged
Conversation
OpenUrzednik.MF.WhiteList.DependencyInjection registers WhiteListClient and WhiteListStatusClient as typed clients of one named HttpClient (AddOpenUrzednikMFWhiteList, AddKeyedOpenUrzednikMFWhiteList), with validated options, per-client telemetry and container metrics, the resilience-rejection handler and display-path logging (ADR-0017). WhiteListRetry.ShouldRetryAsync (base package, ValueTask<bool> for Polly's ShouldHandle) answers whether a response is worth retrying: 400 WL-195/196, 408 and 5xx except 500 WL-197. Only for 400 and 500 it reads the code from the body: at most 4096 bytes, then the response's content is replaced with one that replays them and the rest of the stream, so the error mapping still reads the whole body. The shared layer treats an error body that was already consumed as unreadable instead of throwing. ADR-0023 is corrected in place; .claude/rules/http.md records the rule. Closes #263 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #263
What
OpenUrzednik.MF.WhiteList.DependencyInjection(stillIsPackable=false; MF White List: ship it (packaging and docs) #264 ships it). It is a copy of the NBP DI package.AddOpenUrzednikMFWhiteList()andAddKeyedOpenUrzednikMFWhiteList(key)registerWhiteListClientandWhiteListStatusClient, with their interfaces, as typed clients of one namedHttpClient.IMeterFactory, or the shared meter) (ADR-0025, Metrics: an IMeterFactory path for the DI packages #333).AddOpenUrzednikMFWhiteListRejectionHandler()turns resilience-handler rejections into errors.IHttpClientFactorylogs.WhiteListRetry.ShouldRetryAsync(HttpResponseMessage, CancellationToken)in the base package returnsValueTask<bool>, the type of Polly'sShouldHandledelegate (ADR-0023, Resilience).WL-195/WL-196, 408, and 5xx except 500WL-197. It doesn't retry 429 or anything else.WhiteListReplayContent, which serves those bytes and then the rest of the stream, so the error mapping still reads the whole body.AddStandardResilienceHandler.RestRequestExecutor.ReadServerMessageAsynctreats an error body that was already consumed (.NET) or closed (.NET Framework) as unreadable, instead of throwing. This also protects NBP when an app's handler reads the error body.Stream.ReadAsync(Memory<byte>, ct)polyfill for netstandard2.0, bounded withWaitAsync, because .NET Framework's network streams ignore the token once a read has started.mf-white-list-dimutation shard;slnx/slnfentries, the Architecture tests'SrcAssemblies, AotSmoke DI checks (default and keyed);strykerskill table;Directory.Packages.propscomment.ValueTaskreturn type, how the filter reads the code, and the alternatives it rejected;.claude/rules/http.mdfor any code that reads a response body before the client maps it.Left for #264
READMEs (including the
WhiteListRetrysnippet, added to #264's scope in a comment), icon,check_nuget.py,version.jsonpath filters, release-workflow filters, the package description.Review history
The
revieweragent ran four times:#ifreplaced by a polyfill, and the ADR record.LoadIntoBufferAsync(limit), and the client threw. The reviewer reproduced it on .NET and .NET Framework. The fix is the bounded read plus replay described above, and the shared-layer hardening.Checks run locally
dotnet build OpenUrzednik.slnx -p:TreatWarningsAsErrors=trueWhiteListRetryTestagainst the test host (a real chunked 400WL-118), net10.0 and net472dotnet format --verify-no-changesmf-white-listmf-white-list-dihttp,http-netstandarddotnet pack,package_guard.pymf-white-list-diwas last run before the final rounds of review fixes, which didn't change the DI package's code. CI runs it again.🤖 Generated with Claude Code