Skip to content

Self-evolving Context Database for AI Agents. Unify Agent Memory, Knowledge RAG and Skills.

fix(cli): handle non-UTF-8 filenames in add-resource (#1224)

Matt Van Horn4e2939eee838
diff --git a/crates/ov_cli/src/client.rs b/crates/ov_cli/src/client.rs
index 766878e24..11f7029c0 100644
--- a/crates/ov_cli/src/client.rs
+++ b/crates/ov_cli/src/client.rs
@@ -65,7 +65,10 @@ impl HttpClient {
let path = entry.path();
if path.is_file() {
let name = path.strip_prefix(dir_path).unwrap_or(path);
- zip.start_file(name.to_string_lossy(), options)?;
+ let name_str = name.to_str().ok_or_else(|| {
+ Error::InvalidPath(format!("Non-UTF-8 path: {}", name.to_string_lossy()))
+ })?;
+ zip.start_file(name_str, options)?;
let mut file = File::open(path)?;
std::io::copy(&mut file, &mut zip)?;
}
diff --git a/crates/ov_cli/src/error.rs b/crates/ov_cli/src/error.rs
index 9a2df34ac..d117d406b 100644
--- a/crates/ov_cli/src/error.rs
+++ b/crates/ov_cli/src/error.rs
@@ -20,6 +20,9 @@ pub enum Error {
#[error("Output error: {0}")]
Output(String),
+ #[error("Invalid path: {0}")]
+ InvalidPath(String),
+
#[error("IO error: {0}")]
Io(#[from] std::io::Error),
@@ -76,6 +79,7 @@ impl From<Error> for CliError {
Error::Client(msg) => CliError::new(format!("Client error: {}", msg)),
Error::Parse(msg) => CliError::new(format!("Parse error: {}", msg)),
Error::Output(msg) => CliError::new(format!("Output error: {}", msg)),
+ Error::InvalidPath(msg) => CliError::new(format!("Invalid path: {}", msg)),
Error::Io(e) => CliError::new(format!("IO error: {}", e)),
Error::Serialization(e) => CliError::new(format!("Serialization error: {}", e)),
Error::Zip(e) => CliError::new(format!("Zip error: {}", e)),