fix(rivetkit): preserve bridge error messages#4959
Conversation
|
PR 4959 Review: fix(rivetkit): preserve bridge error messages Overview This PR fixes a bug where error messages were lost when bridging RivetErrors across the NAPI/WASM boundary. The root cause: BridgeRivetErrorContext Display was showing internal debug metadata (public, status_code) instead of the actual error message. Since anyhow Error to_string() renders only the outermost context Display, the human-readable message was invisible at the top level. The fix adds a message field to BridgeRivetErrorContext and routes the actual error text through it. What is correct
Minor observations
Both call sites always pass Some(message). payload.message is a non-optional String, and error.to_string() in actor_context.rs always yields a String. The None fallback (bridged RivetError) is dead code today. Making the field String would be more precise and eliminate the dead branch, though Option is a reasonable future-safe default.
The message is stored in both RivetError::message (inner anyhow error) and BridgeRivetErrorContext::message (outer context). This is required because anyhow to_string() surfaces only the outermost context. The clone at the parse_bridge_rivet_error call site is the minimal overhead needed.
The change in actor_context.rs (capturing error.to_string() before the verify error is consumed) is not covered by a new test. An integration test that triggers a 401 from verify_token and checks the surfaced error message would close this gap. Not a blocker.
BridgeRivetErrorContext is defined independently in actor_factory.rs and rivetkit-wasm/src/lib.rs. This PR correctly keeps both in sync, but a shared crate would eliminate future drift risk. Summary The fix is correct, targeted, and well-tested for its primary paths. No blocking issues. All observations above are minor or pre-existing. |
fb0453e to
d612792
Compare
878a458 to
c2198e9
Compare
d612792 to
99e74a3
Compare
c2198e9 to
7764046
Compare

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: