fix(ragfs): return config error instead of panicking when pathlock manager is missing - #4106
Open
korjavin wants to merge 1 commit into
Open
fix(ragfs): return config error instead of panicking when pathlock manager is missing#4106korjavin wants to merge 1 commit into
korjavin wants to merge 1 commit into
Conversation
…nager is missing MountableFS::mount(), build_multi_write_fs(), and copy_within_mount() called .expect() on the optional pathlock_manager, so any encrypted single-backend mount, multi-write mount, or raw-copy fast path reached on a MountableFS built via the public constructors (which never initialize that manager) panicked instead of returning an error. Replace each .expect() with Error::config(...) via ok_or_else so callers get a normal Result::Err. Adds regression tests covering all three previously-panicking paths. Fixes volcengine#4082
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
MountableFS::mount(),build_multi_write_fs(), andcopy_within_mount()incrates/ragfs/src/core/mountable.rscalled.expect()on the optionalpathlock_manager. The public constructors (MountableFS::new(),with_cache) never initialize that manager, so any of the following reached on a normally-constructed instance panicked instead of returning an error:mount()build_multi_write_fs)copy_within_mount()Fix
Replace each
.expect("pathlock manager must be initialized ...")withError::config(...)viaok_or_else, propagated with?. All three call sites already returnResult, so no signature changes were needed.Tests
Added three regression tests exercising each previously-panicking path on a
MountableFSwith no pathlock manager set, asserting aError::Config(_)is returned instead of a panic:mount_encrypted_single_backend_without_pathlock_manager_returns_config_errorbuild_multi_write_fs_without_pathlock_manager_returns_config_errorcopy_within_mount_without_pathlock_manager_returns_config_errorRan
cargo test -p ragfs --lib— 445 passed, 0 failed, 9 ignored (pre-existing, unrelated).Fixes #4082