fix(api): dont 500 on cross dc response#4449
fix(api): dont 500 on cross dc response#4449MasterPtato wants to merge 1 commit into03-17-chore_update_byte_units_on_frontendfrom
Conversation
|
🚅 Deployed to the rivet-pr-4449 environment in rivet-frontend
|
|
Warning This pull request is not mergeable via GitHub because a downstack PR is open. Once all requirements are satisfied, merge this PR as a stack on Graphite.
This stack of pull requests is managed by Graphite. Learn more about stacking. |
PR Review:
|
29a5224 to
8ee527a
Compare
d4011f0 to
3b845cb
Compare
8ee527a to
5c55237
Compare
3b845cb to
1028b2c
Compare
|
PR Review: fix(api) dont 500 on cross dc response This is a small, focused bug fix that correctly addresses the issue of cross-DC responses being converted to 500 errors. Change Summary: In reqwest_to_axum_response, when a remote DC returned a non-2xx response, anyhow::bail!() was called, which propagated as an internal server error (500) instead of forwarding the actual response status and body to the client. The fix logs the error and allows the response to pass through with its original status code. Whats Good: reqwest_to_axum_response is intended as a raw pass-through so forwarding the original status code and body is the right approach. The new tracing::error! call correctly follows the project logging conventions. The body_bytes borrow via String::from_utf8_lossy is correctly scoped within the if block. Minor Suggestions: (1) Consider using %status (Display) instead of ?status (Debug) for the status code - Display outputs 404 Not Found while Debug adds extra formatting noise. (2) tracing::error! is reasonable but tracing::warn! might reduce log noise if 404s are expected in normal operation. (3) The checklist items in the PR description are unchecked - worth filling in for completeness. Overall this is a correct and minimal fix. LGTM. |
5c55237 to
876713f
Compare
1028b2c to
88d15c3
Compare
PR Review:
|
88d15c3 to
ede07de
Compare
876713f to
3bf4304
Compare
ede07de to
e9536ed
Compare
3bf4304 to
9282590
Compare
e9536ed to
cf68e1c
Compare
9282590 to
bc5319a
Compare
PR Review:
|
bc5319a to
72b27cf
Compare
cf68e1c to
0422e8d
Compare
PR Review: fix(api): dont 500 on cross dc responseThe fix is correct and well-targeted. The Observations
tracing::error!(%status, ?ray_id, %body_text, "remote dc returned error");This would log Log level for 4xx — Logging all non-success responses at if status.is_server_error() {
tracing::error!(%status, ?ray_id, %body_text, "remote dc returned server error");
} else {
tracing::warn!(%status, ?ray_id, %body_text, "remote dc returned client error");
}That said, since this is internal DC-to-DC traffic, 4xx from a peer DC may legitimately indicate a problem worth surfacing as an error — so the current choice is defensible. Contrast with SummaryThe core fix is sound — replacing |
72b27cf to
a9b074b
Compare
a9b074b to
6e86176
Compare
1cb5f34 to
34988dd
Compare
|
PR Review: fix(api) dont 500 on cross dc response Summary This PR fixes a bug where cross-datacenter error responses were causing HTTP 500 errors on the calling service. The root cause was that reqwest_to_axum_response used anyhow::bail! to propagate non-2xx responses from remote DCs, which bubbled up as 500s rather than forwarding the original response. The fix converts the bail! to a tracing::error! log and allows the function to continue building and returning the actual response. The Core Fix Is Correct The change correctly addresses the problem. Previously, when a remote DC returned a non-2xx status, anyhow::bail! would abort reqwest_to_axum_response and propagate an error upward. The caller would treat this as an internal failure and return 500. Now the error is logged and the original status code and body are forwarded transparently. This is semantically correct for a reverse-proxy scenario. Suggestions Consider a doc comment on reqwest_to_axum_response The function contract changed: it now returns Ok even for non-2xx responses. This is intentional and correct for the current callers, but future callers who expect an Err on non-success would silently pass through error responses. A short doc comment would prevent future confusion. Tracing format specifier (minor) %body_text (Display) is correct for Cow. For ?status, using Display (%status) might produce a slightly more readable log line (e.g., 404 Not Found vs StatusCode(404)), though this is minor and ? is not wrong. CLAUDE.md Convention Compliance
No Blocking Issues The fix is correct and well-targeted. The one behavioral nuance worth noting is that non-2xx responses now flow through as Ok rather than propagating as Err. This is intentional and appropriate for the proxy use case. The doc comment suggestion above is optional but would help future maintainers understand the contract. Reviewed by Claude Sonnet 4.6 |
6e86176 to
90bceb5
Compare
34988dd to
388ad2e
Compare
90bceb5 to
ae6bd69
Compare
388ad2e to
b1b526d
Compare
PR Review:
|
b1b526d to
6ab46b0
Compare
ae6bd69 to
0a8136c
Compare
6ab46b0 to
a7a6cca
Compare
0a8136c to
76ac889
Compare
a7a6cca to
3aae0b5
Compare
76ac889 to
3a9d999
Compare

Fixes RVT-6105
Description
Please include a summary of the changes and the related issue. Please also include relevant motivation and context.
Type of change
How Has This Been Tested?
Please describe the tests that you ran to verify your changes.
Checklist: