fix: return tool error for invalid param in computer controller (#1430)

This commit is contained in:
Salman Mohammed
2025-02-27 18:18:38 -05:00
committed by GitHub
parent 025ac83c35
commit 5bf05d545e

View File

@@ -501,7 +501,12 @@ impl ComputerControllerRouter {
})?;
(bytes.to_vec(), "bin")
}
_ => unreachable!(), // Prevented by enum in tool definition
_ => {
return Err(ToolError::InvalidParameters(format!(
"Invalid 'save_as' parameter: {}. Valid options are: 'text', 'json', 'binary'",
save_as
)));
}
};
// Save to cache
@@ -571,7 +576,11 @@ impl ComputerControllerRouter {
script_path.display()
)
}
_ => unreachable!(), // Prevented by enum in tool definition
_ => {
return Err( ToolError::InvalidParameters(
format!("Invalid 'language' parameter: {}. Valid options are: 'shell', 'batch', 'ruby', 'powershell", language)
));
}
};
// Run the script
@@ -712,7 +721,10 @@ impl ComputerControllerRouter {
Ok(vec![Content::text("Cache cleared successfully.")])
}
_ => unreachable!(), // Prevented by enum in tool definition
_ => Err(ToolError::InvalidParameters(format!(
"Invalid 'command' parameter: {}. Valid options are: 'list', 'view', 'delete', 'clear'",
command
)))
}
}
}