Skip to content
Merged
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
31 changes: 29 additions & 2 deletions crates/bashkit/src/scripted_tool/execute.rs
Original file line number Diff line number Diff line change
Expand Up @@ -320,7 +320,7 @@ impl Tool for ScriptedTool {
stdout: String::new(),
stderr: e.to_string(),
exit_code: 1,
error: Some(format!("{:?}", e)),
error: Some(e.to_string()),
},
}
}
Expand Down Expand Up @@ -352,7 +352,7 @@ impl Tool for ScriptedTool {
stdout: String::new(),
stderr: e.to_string(),
exit_code: 1,
error: Some(format!("{:?}", e)),
error: Some(e.to_string()),
},
};

Expand Down Expand Up @@ -452,4 +452,31 @@ mod tests {
usage_from_schema(&serde_json::json!({"type": "object", "properties": {}})).is_none()
);
}

#[tokio::test]
async fn test_error_uses_display_not_debug() {
use super::ScriptedTool;
use crate::tool::Tool;
use crate::ToolDef;

let mut tool = ScriptedTool::builder("test")
.short_description("test")
.tool(
ToolDef::new("fail", "Always fails"),
|_args: &super::ToolArgs| Err("service error".to_string()),
)
.build();
let req = ToolRequest {
commands: "fail".into(),
timeout_ms: None,
};
let resp = tool.execute(req).await;
// Error messages use Display format, not Debug, to avoid leaking internals
if let Some(ref err) = resp.error {
assert!(
!err.contains("Execution("),
"error should use Display not Debug: {err}",
);
}
}
}
Loading