Skip to content

enhancement: Forward 5XX 4XX from source to client - #2031

Open
entrop-tankos wants to merge 1 commit into
dragonflyoss:mainfrom
entrop-tankos:error-code-forwarding
Open

enhancement: Forward 5XX 4XX from source to client#2031
entrop-tankos wants to merge 1 commit into
dragonflyoss:mainfrom
entrop-tankos:error-code-forwarding

Conversation

@entrop-tankos

Copy link
Copy Markdown
Contributor

Description

This change improves proxy-mode error propagation by forwarding backend HTTP error responses more transparently to the client.

Previously, when a backend/origin returned a non-success HTTP status, dfdaemon could preserve the status code in some cases, but the response body was lost on the proxy path. As a result, clients only saw the status code and could not access the backend-provided error message.

With this patch, when dfdaemon is used as an HTTP proxy and the backend returns a non-success response before normal body streaming starts, dfdaemon now forwards:

the backend HTTP status code,
the backend response headers,
the backend response body, if present.

This applies to proxy-mode error handling and preserves important backend-side context for callers.
Related Issue

N/A
Motivation and Context

Some origins return meaningful error details in the response body together with 4xx/5xx statuses. Typical examples include:

quota exceeded,
request rate limiting,
temporary bans,
access restrictions,
backend-specific retry hints.

That information is important for clients building their own retry and backoff logic on top of Dragonfly.

Without the response body, the caller only sees a generic HTTP error code and loses the backend-specific reason, which makes it much harder to distinguish between retryable and non-retryable failures.

This patch fixes that behavior by preserving and forwarding the backend error body to the client when available.

@codecov

codecov Bot commented Sep 4, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 10.07752% with 116 lines in your changes missing coverage. Please review.
✅ Project coverage is 54.44%. Comparing base (72fd774) to head (249e78b).

Files with missing lines Patch % Lines
dragonfly-client/src/proxy/mod.rs 0.00% 80 Missing ⚠️
dragonfly-client-backend/src/http.rs 38.88% 11 Missing ⚠️
dragonfly-client-backend/src/object_storage.rs 45.45% 6 Missing ⚠️
dragonfly-client-backend/src/hdfs.rs 0.00% 5 Missing ⚠️
dragonfly-client-backend/src/hugging_face.rs 0.00% 4 Missing ⚠️
dragonfly-client-backend/src/model_scope.rs 0.00% 4 Missing ⚠️
dragonfly-client-backend/src/opencsg.rs 0.00% 4 Missing ⚠️
dragonfly-client/src/proxy/task.rs 0.00% 2 Missing ⚠️
Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main    #2031      +/-   ##
==========================================
- Coverage   54.64%   54.44%   -0.20%     
==========================================
  Files         101      101              
  Lines       27460    27570     +110     
==========================================
+ Hits        15005    15010       +5     
- Misses      12455    12560     +105     
Files with missing lines Coverage Δ
dragonfly-client-backend/src/lib.rs 92.85% <ø> (ø)
dragonfly-client-core/src/error/errors.rs 87.50% <ø> (ø)
dragonfly-client-util/src/http/mod.rs 99.43% <100.00%> (+<0.01%) ⬆️
dragonfly-client/src/proxy/header.rs 85.19% <ø> (ø)
dragonfly-client/src/resource/persistent_task.rs 0.00% <ø> (ø)
dragonfly-client/src/resource/piece.rs 36.23% <ø> (ø)
dragonfly-client/src/resource/task.rs 3.04% <ø> (ø)
dragonfly-client/src/proxy/task.rs 0.00% <0.00%> (ø)
dragonfly-client-backend/src/hugging_face.rs 77.08% <0.00%> (-0.75%) ⬇️
dragonfly-client-backend/src/model_scope.rs 84.24% <0.00%> (-0.64%) ⬇️
... and 5 more

... and 1 file with indirect coverage changes

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

@entrop-tankos entrop-tankos changed the title Forward 5XX 4XX from source to client enhancement: Forward 5XX 4XX from source to client Sep 5, 2026
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.

1 participant