Skip to content

Fail fast on status-bearing HttpRequestException#398

Merged
ptr727 merged 3 commits into
developfrom
feature/refine-httprequest-transient
Jul 10, 2026
Merged

Fail fast on status-bearing HttpRequestException#398
ptr727 merged 3 commits into
developfrom
feature/refine-httprequest-transient

Conversation

@ptr727

@ptr727 ptr727 commented Jul 10, 2026

Copy link
Copy Markdown
Owner

Summary

Refines HttpClientFactory.IsTransientFailure so a status-bearing HttpRequestException (one whose StatusCode is set, e.g. from EnsureSuccessStatusCode) is transient only for a transient status code (408/429/>= 500). A HttpRequestException with 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 HttpRequestException is 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-changes clean.

Addresses a Copilot finding on the develop->main release PR (#394).

🤖 Generated with Claude Code

Copilot AI review requested due to automatic review settings July 10, 2026 19:40
@codecov

codecov Bot commented Jul 10, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 46.37%. Comparing base (b0c32f8) to head (94e776a).

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.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.IsTransientFailure to treat status-bearing HttpRequestException as transient only for 408/429/>=500.
  • Add a resilience test asserting that a 404 status-bearing HttpRequestException is 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.

Comment thread Utilities/HttpClientFactory.cs Outdated
Comment thread UtilitiesTests/HttpClientFactoryResilienceTests.cs Outdated
Copilot AI review requested due to automatic review settings July 10, 2026 19:44

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.

Comment thread UtilitiesTests/HttpClientFactoryResilienceTests.cs
Comment thread Utilities/HttpClientFactory.cs Outdated
Copilot AI review requested due to automatic review settings July 10, 2026 19:48

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 2 out of 2 changed files in this pull request and generated no new comments.

@ptr727
ptr727 merged commit 7eff371 into develop Jul 10, 2026
12 checks passed
@ptr727
ptr727 deleted the feature/refine-httprequest-transient branch July 10, 2026 19:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants