Skip to content
Open
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
1 change: 1 addition & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

20 changes: 20 additions & 0 deletions crates/ragfs-python/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,7 @@ fn pathlock_err_to_py(err: PathLockError) -> PyErr {
})
}
PathLockError::InvalidRequest(_) => PyValueError::new_err(err.to_string()),
PathLockError::InvalidPath(_) => new_py_err("AGFSInvalidPathError", err.to_string()),
PathLockError::Io(_) | PathLockError::InvalidToken(_) | PathLockError::Internal(_) => {
new_py_err("AGFSInternalError", err.to_string())
}
Expand Down Expand Up @@ -3090,6 +3091,25 @@ mod tests {
});
}

#[test]
fn pathlock_invalid_path_preserves_public_error_type() {
Python::initialize();
Python::attach(|py| {
let invalid_path_type = get_exception(py, "AGFSInvalidPathError").unwrap();
for wrapped in [false, true] {
let error = PathLockError::InvalidPath(
"path must match existing entry names exactly".to_string(),
);
let error = if wrapped {
to_py_err(error.into())
} else {
pathlock_err_to_py(error)
};
assert!(error.is_instance(py, &invalid_path_type));
}
});
}

#[test]
fn pathlock_contention_survives_filesystem_wrappers() {
Python::initialize();
Expand Down
3 changes: 3 additions & 0 deletions crates/ragfs/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,9 @@ grep-searcher = "0.1.16"
[target.'cfg(windows)'.dependencies]
windows-sys = { version = "0.61", features = ["Win32_Foundation", "Win32_Storage_FileSystem"] }

[target.'cfg(any(target_os = "macos", target_os = "linux"))'.dependencies]
libc = "0.2"

# Development dependencies
[dev-dependencies]
tempfile = "3.12"
Expand Down
4 changes: 4 additions & 0 deletions crates/ragfs/src/lock/provider.rs
Original file line number Diff line number Diff line change
Expand Up @@ -282,6 +282,10 @@ impl FilesystemPathLockProvider {
crate::core::Error::NotFound(_) | crate::core::Error::MountPointNotFound(_)
) {
Ok(None)
} else if let crate::core::Error::InvalidPath(message) = e {
Err(PathLockError::InvalidPath(format!(
"failed to read lock token at '{lock_path}': {message}"
)))
} else {
Err(PathLockError::Io(format!(
"failed to read lock token at '{lock_path}': {e}"
Expand Down
4 changes: 4 additions & 0 deletions crates/ragfs/src/lock/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,10 @@ pub enum PathLockError {
operation: String,
},

/// Invalid path while resolving lock storage.
#[error("invalid path: {0}")]
InvalidPath(String),

/// I/O error during lock operation.
#[error("lock I/O error: {0}")]
Io(String),
Expand Down
Loading
Loading