Skip to content

The fastest, cheapest, most efficient open-source agent harness. Run more than 500 agents on a $10 VPS.

fix(channels): sanitize module callback errors to avoid leaking provider details

Steven Enamakel5db7965d967f
diff --git a/crates/openhuman-core/src/channels/runtime/startup/progressive_transport.rs b/crates/openhuman-core/src/channels/runtime/startup/progressive_transport.rs
index da145b99b2..b7457bb084 100644
--- a/crates/openhuman-core/src/channels/runtime/startup/progressive_transport.rs
+++ b/crates/openhuman-core/src/channels/runtime/startup/progressive_transport.rs
@@ -145,9 +145,7 @@ impl ProgressiveChannelTransport for ModuleChannel {
Ok(_) => Err(tinybus::Error::failed(
"channel returned an invalid edit result",
)),
- Err(error) => Err(tinybus::Error::failed(format!(
- "channel edit callback failed: {error}"
- ))),
+ Err(error) => Err(sanitize_module_error("edit", error)),
}
}
Request::Delete {
@@ -180,9 +178,7 @@ impl ProgressiveChannelTransport for ModuleChannel {
Ok(_) => Err(tinybus::Error::failed(
"channel returned an invalid delete result",
)),
- Err(error) => Err(tinybus::Error::failed(format!(
- "channel delete callback failed: {error}"
- ))),
+ Err(error) => Err(sanitize_module_error("delete", error)),
}
}
Request::Typing { conversation, .. } => {
@@ -199,6 +195,10 @@ impl ProgressiveChannelTransport for ModuleChannel {
}
}
+fn sanitize_module_error(operation: &str, _source: impl std::fmt::Display) -> tinybus::Error {
+ tinybus::Error::failed(format!("channel {operation} callback failed"))
+}
+
fn map_edit_outcome(
outcome: tinychannels_bus::channel::ChannelSendOutcome,
) -> tinychannels_bus::module_progressive::ProgressiveTransportResult {
diff --git a/crates/openhuman-core/src/channels/runtime/startup/progressive_transport_tests.rs b/crates/openhuman-core/src/channels/runtime/startup/progressive_transport_tests.rs
index 0d11e61dab..040e6521f0 100644
--- a/crates/openhuman-core/src/channels/runtime/startup/progressive_transport_tests.rs
+++ b/crates/openhuman-core/src/channels/runtime/startup/progressive_transport_tests.rs
@@ -25,6 +25,18 @@ fn forbidden_edit_error_is_preserved_instead_of_reported_as_unsupported() {
assert!(!error.unsupported);
}
+#[test]
+fn module_callback_error_does_not_expose_provider_details() {
+ let error = sanitize_module_error(
+ "edit",
+ "request failed for https://api.invalid/bot?token=SECRET",
+ );
+
+ assert!(error.to_string().contains("channel edit callback failed"));
+ assert!(!error.to_string().contains("SECRET"));
+ assert!(!error.to_string().contains("api.invalid"));
+}
+
#[test]
fn receipt_scope_requires_exact_channel_and_full_conversation_identity() {
use tinychannels_bus::channel::{types::ConversationKind, MessageReceipt};