Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use contextforge_gateway_rs_apis::user_store::VirtualHost;
use rmcp::{ErrorData, model::ErrorCode};
use rmcp::{ErrorData, model::ErrorCode, service::ServiceError};
use tracing::{debug, warn};

use super::{
Expand Down Expand Up @@ -65,13 +65,16 @@ pub(super) fn exposed_tool_name(virtual_host: &VirtualHost, backend_name: &str,
})
}

/// Logs a backend forwarding failure and maps it to the routing error every handler returns.
pub(super) fn backend_forward_error(op: &str, backend_name: &str, error: &impl std::fmt::Debug) -> ErrorData {
warn!("{op}: backend {backend_name} {error:?}");
ErrorData {
code: ErrorCode::INTERNAL_ERROR,
message: "Routing problem... got no responses from backends".into(),
data: None,
pub(super) fn backend_forward_error(op: &str, backend_name: &str, error: &ServiceError) -> ErrorData {
warn!("{op}: backend {backend_name} error = {error:?}");

match error {
ServiceError::McpError(mcp_error) => mcp_error.to_owned(),
_ => ErrorData {
code: ErrorCode::INTERNAL_ERROR,
message: "Routing problem... got no responses from backends".into(),
data: None,
},
}
}

Expand All @@ -85,7 +88,7 @@ pub(super) async fn route_identifier_to_backend(
) -> Result<(String, McpClientService, String), ErrorData> {
let backend_names = session_manager.get_backend_names();
let Some((backend_name, routed_identifier)) = route_identifier(identifier, &backend_names) else {
return Err(ErrorData { code: ErrorCode::INTERNAL_ERROR, message: no_route_message.into(), data: None });
return Err(ErrorData { code: ErrorCode::INVALID_PARAMS, message: no_route_message.into(), data: None });
};
let routed_identifier = routed_identifier.to_owned();
let (backend_name, service) = resolve_backend(session_manager, op, backend_name).await?;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ where
&session_manager,
"get_prompt",
&request.name,
"Routing problem... wrong prompt name",
"Routing problem... invalid prompt name",
)
.await?;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,8 @@ where

let Some((backend_name, tool_name)) = resolve_tool_route(virtual_host, &request.name, &backend_names) else {
return Err(ErrorData {
code: ErrorCode::INTERNAL_ERROR,
message: "Routing problem... wrong tool name".into(),
code: ErrorCode::INVALID_PARAMS,
message: "Routing problem... tool not found".into(),
data: None,
});
};
Expand Down
3 changes: 2 additions & 1 deletion deny.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
[advisories]
ignore = [
{id="RUSTSEC-2023-0071" , reason = "1. For time being not in production. 2. Workaround would be to force customers to use EC keys instead of RSA" }
{id="RUSTSEC-2023-0071" , reason = "1. For time being not in production. 2. Workaround would be to force customers to use EC keys instead of RSA" },
{id="RUSTSEC-2026-0214" , reason = "1. gumdrop is used by goose which is a dev tool only" }
]

[[licenses.exceptions]]
Expand Down