Fail fast on status-bearing HttpRequestException#398
Merged
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## develop #398 +/- ##
===========================================
+ Coverage 46.19% 46.37% +0.18%
===========================================
Files 13 13
Lines 1156 1160 +4
Branches 107 108 +1
===========================================
+ Hits 534 538 +4
Misses 592 592
Partials 30 30 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
Contributor
There was a problem hiding this comment.
Pull request overview
Refines the resilience retry classification in HttpClientFactory so HttpRequestException instances that include an HTTP status code only retry for transient status codes (408/429/>=500), while status-less network/IO exceptions remain transient. Adds a regression test ensuring 404 status-bearing exceptions fail fast (no retry), addressing a prior review finding from the v4.0 promotion PR.
Changes:
- Update
HttpClientFactory.IsTransientFailureto treat status-bearingHttpRequestExceptionas transient only for 408/429/>=500. - Add a resilience test asserting that a 404 status-bearing
HttpRequestExceptionis not retried.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| Utilities/HttpClientFactory.cs | Tightens transient-failure detection for HttpRequestException based on presence/value of StatusCode. |
| UtilitiesTests/HttpClientFactoryResilienceTests.cs | Adds regression coverage for non-transient status-bearing HttpRequestException (404) ensuring fail-fast behavior. |
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.
Summary
Refines
HttpClientFactory.IsTransientFailureso a status-bearingHttpRequestException(one whoseStatusCodeis set, e.g. fromEnsureSuccessStatusCode) is transient only for a transient status code (408/429/>= 500). AHttpRequestExceptionwith no status (a network/IO error) stays transient. This prevents retrying 4xx failures (400/401/404) that should fail fast.Adds a test: a 404
HttpRequestExceptionis not retried; the existing network-exception test (no status) still retries.Verification
dotnet build- 0 warnings / 0 errors.dotnet test- resilience suite green (+1).dotnet format style --verify-no-changesclean.Addresses a Copilot finding on the develop->main release PR (#394).
🤖 Generated with Claude Code