Skip to content

Conversation

chlins
Copy link
Member

@chlins chlins commented Aug 21, 2025

This pull request enhances error handling and reporting throughout the dragonfly-client project, focusing on more explicit error typing and improved communication of error sources to clients via HTTP response headers. The main changes include introducing a new error type system, updating error responses to include error source information, and refactoring code to utilize these new mechanisms.

Error Type System and Header Reporting:

  • Added a new ErrorType enum in dragonfly-client/src/proxy/header.rs to represent the source of errors (Backend, Proxy, Dfdaemon), along with a corresponding HTTP header X-Dragonfly-Error-Type for error responses. This helps clients identify where an error originated.

  • Refactored the make_error_response function in dragonfly-client/src/proxy/mod.rs to require an ErrorType argument and to set the error type header in all error responses. All error response creation sites throughout the proxy code were updated to use this new function signature and provide the appropriate error type. [1] [2]

Proxy Error Handling Improvements:

  • Updated proxy handler functions (http_handler, https_handler, upgraded_handler, and proxy_via_http) to use the new error type system when returning error responses, ensuring clients can distinguish between proxy, backend, and dfdaemon errors. [1] [2] [3] [4]

  • Enhanced error reporting in proxy_via_dfdaemon to set the correct error type in all error response paths, including backend failures, dfdaemon failures, and general errors, improving traceability for clients. [1] [2] [3] [4] [5] [6] [7] [8] [9]

Backend Error Propagation:

  • Modified error propagation in the HTTP backend implementation (dragonfly-client-backend/src/http.rs) to return structured error responses with explicit success flags and error messages, rather than propagating errors via inspect_err. This makes error handling more robust and consistent. [1] [2] [3]

Resource Task Error Handling:

  • Updated the Task implementation in dragonfly-client/src/resource/task.rs to use the new error response structure, passing through optional status code and header fields directly, improving error information fidelity.

Description

Related Issue

Motivation and Context

Screenshots (if appropriate)

@chlins chlins added the enhancement New feature or request label Aug 21, 2025
Copy link

codecov bot commented Aug 21, 2025

Codecov Report

❌ Patch coverage is 45.09804% with 28 lines in your changes missing coverage. Please review.
✅ Project coverage is 48.55%. Comparing base (a756f50) to head (e9a40fc).
⚠️ Report is 3 commits behind head on main.

Files with missing lines Patch % Lines
dragonfly-client/src/proxy/header.rs 0.00% 16 Missing ⚠️
dragonfly-client/src/proxy/mod.rs 0.00% 12 Missing ⚠️
Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main    #1299      +/-   ##
==========================================
- Coverage   48.58%   48.55%   -0.04%     
==========================================
  Files          60       60              
  Lines       15154    15196      +42     
==========================================
+ Hits         7363     7378      +15     
- Misses       7791     7818      +27     
Files with missing lines Coverage Δ
dragonfly-client-backend/src/http.rs 98.20% <100.00%> (+0.07%) ⬆️
dragonfly-client/src/resource/task.rs 8.13% <ø> (ø)
dragonfly-client/src/proxy/mod.rs 0.00% <0.00%> (ø)
dragonfly-client/src/proxy/header.rs 86.00% <0.00%> (-6.07%) ⬇️
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Copy link
Member

@gaius-qi gaius-qi left a comment

Choose a reason for hiding this comment

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

LG

@chlins chlins force-pushed the feat/proxy-status-header branch 2 times, most recently from 681cb6a to f8641c2 Compare August 21, 2025 12:53
@chlins chlins enabled auto-merge (squash) August 21, 2025 13:04
@chlins chlins force-pushed the feat/proxy-status-header branch from f8641c2 to afc757a Compare August 22, 2025 07:14
@chlins chlins changed the title feat: add the X-Dragonfly-Proxy-Status header to the response feat: add the X-Dragonfly-Error-Type header to the response Aug 22, 2025
@chlins chlins force-pushed the feat/proxy-status-header branch from afc757a to f3c8a99 Compare August 22, 2025 07:16
gaius-qi
gaius-qi previously approved these changes Aug 22, 2025
Copy link
Member

@gaius-qi gaius-qi left a comment

Choose a reason for hiding this comment

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

LGTM

Signed-off-by: chlins <chlins.zhang@gmail.com>
@chlins chlins force-pushed the feat/proxy-status-header branch from 524c871 to e9a40fc Compare August 22, 2025 09:45
Copy link
Contributor

@LunaWhispers LunaWhispers left a comment

Choose a reason for hiding this comment

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

lgtm

Copy link
Member

@gaius-qi gaius-qi left a comment

Choose a reason for hiding this comment

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

LGTM

@chlins chlins merged commit 190dead into main Aug 22, 2025
7 checks passed
@chlins chlins deleted the feat/proxy-status-header branch August 22, 2025 10:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants