fix: stop retrying artifact upload on non-retryable status codes#6449
Merged
Conversation
On netstandard2.0 HttpRequestException carries no StatusCode, so IsRetryable fell back to a message heuristic that only excluded 401/403. A GitHub Enterprise Server 404 (the Actions Results artifact API does not exist there) therefore burned the full 5-attempt backoff schedule, adding roughly 25-30s to every run. Introduce ArtifactUploadException carrying the status code on every target framework, so retry decisions are code-driven rather than string-driven. IsRetryable is now an allowlist of transient codes (408, 429, 500, 502, 503, 504); everything else fails on the first attempt. 404 responses gain a hint that the artifact API is unavailable on this host. Non-retryable failures still propagate out of UploadAsync so the CreateArtifact name-dedup loop does not re-issue the same doomed request three times.
thomhurst
enabled auto-merge (squash)
July 19, 2026 11:53
This was referenced Jul 19, 2026
This was referenced Jul 20, 2026
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.
Description
Follow-up to discussion #6448 (GitHub Enterprise Server users waiting ~30s for the HTML report artifact upload to fail).
GHES doesn't implement the Actions Results artifact API that
actions/upload-artifact@v4+— and TUnit's in-process uploader — depend on, soCreateArtifactreturns 404. That should fail immediately, but onnetstandard2.0it didn't:A 404 was therefore treated as retryable and burned the whole 5-attempt backoff schedule (3s → 4.5s → 6.75s → 10.1s, plus jitter ≈ 25-30s) before surfacing the identical error.
Changes
ArtifactUploadException, which carries the HTTP status code on every target framework.EnsureSuccessAsyncthrows it instead ofHttpRequestException, removing both the#if NETsplit and the string heuristic.IsRetryable(int?)is now an allowlist of genuinely transient codes:408, 429, 500, 502, 503, 504(408 is new). Everything else — 404, 401, 403, 400, 422 — fails on the first attempt.UploadAsync, so theCreateArtifactname-dedup loop doesn't re-issue the same doomed request three times.HtmlReportercatches and warns exactly as before.Complements #6447 rather than replacing it — that flag is still the way to skip the upload entirely; this makes the un-flagged path cost one request instead of five.
Type of Change
Testing
14 new
IsRetryablecases inTUnit.Engine.Tests/GitHubArtifactUploaderTests.cscovering the transient allowlist, the non-retryable codes (incl. the GHES 404), and the no-status case. 20/20 pass on net10.0.No source generator or public API surface touched, so no snapshot updates required.