Skip to content

Commit cad72fe

Browse files
committed
Fix(guard): return error response on router error (#2540)
<!-- Please make sure there is an issue that this PR is correlated to. --> ## Changes <!-- If there are frontend changes, please include screenshots. -->
1 parent 6fb6e53 commit cad72fe

File tree

2 files changed

+21
-4
lines changed

2 files changed

+21
-4
lines changed

packages/edge/infra/guard/server/src/routing/api.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
use chirp_workflow::prelude::*;
22
use cluster::types::{Filter, PoolType};
33
use global_error::GlobalResult;
4-
use rivet_guard_core::proxy_service::{RouteConfig, RouteTarget, RoutingOutput, RoutingTimeout, StructuredResponse};
4+
use rivet_guard_core::proxy_service::{
5+
RouteConfig, RouteTarget, RoutingOutput, RoutingTimeout, StructuredResponse,
6+
};
57
use rivet_guard_core::status::StatusCode;
68
use std::borrow::Cow;
79
use uuid::Uuid;

packages/edge/infra/guard/server/src/routing/mod.rs

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,12 @@ pub fn create_routing_function(
5858
}
5959
Err(err) => {
6060
tracing::error!("Error in route_via_route_config: {err}");
61-
// Continue to next routing method
61+
62+
return Ok(RoutingOutput::Response(StructuredResponse {
63+
status: StatusCode::INTERNAL_SERVER_ERROR,
64+
message: Cow::Borrowed("Failed while attempting to route request."),
65+
docs: None,
66+
}));
6267
}
6368
}
6469

@@ -75,7 +80,12 @@ pub fn create_routing_function(
7580
}
7681
Err(err) => {
7782
tracing::error!("Error in actor_routes::route_actor_request: {err}");
78-
// Continue to next routing method
83+
84+
return Ok(RoutingOutput::Response(StructuredResponse {
85+
status: StatusCode::INTERNAL_SERVER_ERROR,
86+
message: Cow::Borrowed("Failed while attempting to route request."),
87+
docs: None,
88+
}));
7989
}
8090
}
8191

@@ -94,7 +104,12 @@ pub fn create_routing_function(
94104
}
95105
Err(err) => {
96106
tracing::error!("Error in api::route_api_request: {err}");
97-
// Continue to next routing method
107+
108+
return Ok(RoutingOutput::Response(StructuredResponse {
109+
status: StatusCode::INTERNAL_SERVER_ERROR,
110+
message: Cow::Borrowed("Failed while attempting to route request."),
111+
docs: None,
112+
}));
98113
}
99114
}
100115

0 commit comments

Comments
 (0)