Skip to content

fix(api): dont 500 on cross dc response#4449

Open
MasterPtato wants to merge 1 commit into03-17-chore_update_byte_units_on_frontendfrom
03-17-fix_api_dont_500_on_cross_dc_response
Open

fix(api): dont 500 on cross dc response#4449
MasterPtato wants to merge 1 commit into03-17-chore_update_byte_units_on_frontendfrom
03-17-fix_api_dont_500_on_cross_dc_response

Conversation

@MasterPtato
Copy link
Contributor

@MasterPtato MasterPtato commented Mar 17, 2026

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

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • This change requires a documentation update

How Has This Been Tested?

Please describe the tests that you ran to verify your changes.

Checklist:

  • My code follows the style guidelines of this project
  • I have performed a self-review of my code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes

@railway-app
Copy link

railway-app bot commented Mar 17, 2026

🚅 Deployed to the rivet-pr-4449 environment in rivet-frontend

Service Status Web Updated (UTC)
frontend-cloud 😴 Sleeping (View Logs) Web Mar 24, 2026 at 8:48 am
frontend-inspector 😴 Sleeping (View Logs) Web Mar 19, 2026 at 12:12 pm
website ❌ Build Failed (View Logs) Web Mar 17, 2026 at 10:41 pm
mcp-hub ✅ Success (View Logs) Web Mar 17, 2026 at 10:40 pm
ladle ❌ Build Failed (View Logs) Web Mar 17, 2026 at 10:39 pm

Copy link
Contributor Author

MasterPtato commented Mar 17, 2026

@linear
Copy link

linear bot commented Mar 17, 2026

@pkg-pr-new
Copy link

pkg-pr-new bot commented Mar 17, 2026

More templates

@rivetkit/cloudflare-workers

pnpm add https://pkg.pr.new/rivet-dev/rivet/@rivetkit/cloudflare-workers@4449

@rivetkit/framework-base

pnpm add https://pkg.pr.new/rivet-dev/rivet/@rivetkit/framework-base@4449

@rivetkit/next-js

pnpm add https://pkg.pr.new/rivet-dev/rivet/@rivetkit/next-js@4449

@rivetkit/react

pnpm add https://pkg.pr.new/rivet-dev/rivet/@rivetkit/react@4449

rivetkit

pnpm add https://pkg.pr.new/rivet-dev/rivet/rivetkit@4449

@rivetkit/sql-loader

pnpm add https://pkg.pr.new/rivet-dev/rivet/@rivetkit/sql-loader@4449

@rivetkit/sqlite-vfs

pnpm add https://pkg.pr.new/rivet-dev/rivet/@rivetkit/sqlite-vfs@4449

@rivetkit/traces

pnpm add https://pkg.pr.new/rivet-dev/rivet/@rivetkit/traces@4449

@rivetkit/workflow-engine

pnpm add https://pkg.pr.new/rivet-dev/rivet/@rivetkit/workflow-engine@4449

@rivetkit/virtual-websocket

pnpm add https://pkg.pr.new/rivet-dev/rivet/@rivetkit/virtual-websocket@4449

@rivetkit/engine-runner

pnpm add https://pkg.pr.new/rivet-dev/rivet/@rivetkit/engine-runner@4449

@rivetkit/engine-runner-protocol

pnpm add https://pkg.pr.new/rivet-dev/rivet/@rivetkit/engine-runner-protocol@4449

commit: 876713f

@claude
Copy link

claude bot commented Mar 17, 2026

PR Review: fix(api): dont 500 on cross dc response

Summary

This is a minimal, well-targeted fix in engine/packages/api-util/src/lib.rs in reqwest_to_axum_response.

Before: When a remote DC returned a non-2xx response, anyhow::bail! propagated an Err up the call stack, causing the API handler to respond with HTTP 500.

After: Logs the error via tracing::error! and falls through to return the actual remote response, preserving the original status code and body.


Feedback

Correctness: ✅

The fix is correct. reqwest_to_axum_response should convert a reqwest response to an axum response — a non-2xx upstream status is not a programming error, it's a valid response to be forwarded. Bailing here was the wrong abstraction.

Logging: ✅

The structured logging conversion is well done and aligns with CLAUDE.md: "Do not format parameters into the main message, instead use tracing's structured logging."

Minor observation:

?status (Debug) prints as StatusCode(404) while %status (Display) would print as 404 Not Found, which is slightly more readable. Not blocking, just worth noting.


Verdict

Looks good to merge. Simple, correct fix with minimal blast radius.

@MasterPtato MasterPtato force-pushed the 03-17-fix_api_dont_500_on_cross_dc_response branch from 29a5224 to 8ee527a Compare March 18, 2026 22:12
@MasterPtato MasterPtato force-pushed the 03-17-chore_update_byte_units_on_frontend branch from d4011f0 to 3b845cb Compare March 18, 2026 22:12
@MasterPtato MasterPtato force-pushed the 03-17-fix_api_dont_500_on_cross_dc_response branch from 8ee527a to 5c55237 Compare March 21, 2026 01:55
@MasterPtato MasterPtato force-pushed the 03-17-chore_update_byte_units_on_frontend branch from 3b845cb to 1028b2c Compare March 21, 2026 01:55
@MasterPtato MasterPtato mentioned this pull request Mar 21, 2026
11 tasks
@claude
Copy link

claude bot commented Mar 21, 2026

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.

@MasterPtato MasterPtato force-pushed the 03-17-fix_api_dont_500_on_cross_dc_response branch from 5c55237 to 876713f Compare March 24, 2026 00:30
@MasterPtato MasterPtato force-pushed the 03-17-chore_update_byte_units_on_frontend branch from 1028b2c to 88d15c3 Compare March 24, 2026 00:30
@MasterPtato MasterPtato mentioned this pull request Mar 24, 2026
11 tasks
@claude
Copy link

claude bot commented Mar 24, 2026

PR Review: fix(api): dont 500 on cross dc response

Overall: Clean, correct, minimal fix.

What the change does

In reqwest_to_axum_response, when a remote DC returns a non-2xx response, the old code called anyhow::bail! which propagated as a 500, discarding the actual remote response. The fix replaces that with a tracing::error! log and lets the function continue to forward the remote DC's actual status code, headers, and body to the caller.

Correctness

The fix is correct. The function's job is to convert a reqwest::Response into an Axum Response — including error responses. Bailing on non-2xx statuses was the bug: it prevented legitimate error responses (404, 429, etc.) from being forwarded to the client.

Logging style

The new tracing::error! call matches project conventions correctly:

tracing::error!(?status, ?ray_id, %body_text, "remote dc returned error");

Structured fields with ? for Debug, % for Display, lowercase message — all good.

Minor concern: log level

error is used unconditionally for all non-2xx responses, including 4xx client errors like 404 or 400. This may produce noisy error logs for expected client errors. Consider differentiating by status class:

if status.is_server_error() {
    tracing::error!(?status, ?ray_id, %body_text, "remote dc returned error");
} else {
    tracing::warn!(?status, ?ray_id, %body_text, "remote dc returned error");
}

Or use warn consistently since the caller receives the full response and can decide how to handle it. This is a minor nit — the core fix is sound either way.

@MasterPtato MasterPtato force-pushed the 03-17-chore_update_byte_units_on_frontend branch from 88d15c3 to ede07de Compare March 24, 2026 00:36
@MasterPtato MasterPtato force-pushed the 03-17-fix_api_dont_500_on_cross_dc_response branch from 876713f to 3bf4304 Compare March 24, 2026 00:36
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