From d668a9293ffe555a1ae21587dda3cbd1c6ffe192 Mon Sep 17 00:00:00 2001 From: Zhengchao An Date: Thu, 13 Aug 2026 03:37:00 +0800 Subject: [PATCH] chore(ecstore): remove test-only BitrotErrorType and pin wire-only disk variants (#6032) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit BitrotErrorType (disk/error.rs) was constructed only by its own unit test: production bitrot mismatches never flow through it (they surface as DiskError::other strings). Delete the enum, its From for DiskError impl, the self-test, and the api facade re-export. The facade inventory doc does not name the type, so no doc change is needed. DiskError::SourceStalled and DiskError::CrossDeviceLink are never constructed locally — they are reachable only through wire decoding and no current node sends them. Their decode arms stay per the cross-version compatibility constraint; each variant now carries a doc comment saying exactly that so the next dead-code sweep does not re-litigate them. Their consumer arms (heal classifier, batch processor) are left untouched — the values cannot appear, so removing the arms would be unobservable, and the heal classifier is pinned by the issue as do-not-touch. Ref rustfs/backlog#1831 (PR4). --- crates/ecstore/src/api/mod.rs | 2 +- crates/ecstore/src/disk/error.rs | 32 ++++++-------------------------- 2 files changed, 7 insertions(+), 27 deletions(-) diff --git a/crates/ecstore/src/api/mod.rs b/crates/ecstore/src/api/mod.rs index 50f2202a7..4b3162313 100644 --- a/crates/ecstore/src/api/mod.rs +++ b/crates/ecstore/src/api/mod.rs @@ -346,7 +346,7 @@ pub mod disk { } pub mod error { - pub use crate::disk::error::{BitrotErrorType, DiskError, Error, FileAccessDeniedWithContext, Result}; + pub use crate::disk::error::{DiskError, Error, FileAccessDeniedWithContext, Result}; } pub mod error_reduce { diff --git a/crates/ecstore/src/disk/error.rs b/crates/ecstore/src/disk/error.rs index c01161846..51fb04daa 100644 --- a/crates/ecstore/src/disk/error.rs +++ b/crates/ecstore/src/disk/error.rs @@ -113,6 +113,9 @@ pub enum DiskError { #[error("bit-rot hash algorithm is invalid")] BitrotHashAlgoInvalid, + /// Never constructed locally by RustFS (only reachable through wire + /// decoding, and no current node sends it). The wire code is kept for + /// cross-version compatibility — do not renumber or remove (backlog#1831). #[error("Rename across devices not allowed, please fix your backend configuration")] CrossDeviceLink, @@ -143,6 +146,9 @@ pub enum DiskError { #[error("io error {0}")] Io(#[source] io::Error), + /// Never constructed locally by RustFS (only reachable through wire + /// decoding, and no current node sends it). The wire code is kept for + /// cross-version compatibility — do not renumber or remove (backlog#1831). #[error("source stalled")] SourceStalled, @@ -642,19 +648,6 @@ impl Hash for DiskError { // is currently commented out to avoid complexity. These can be re-enabled // when needed for specific disk quorum checking and error aggregation logic. -/// Bitrot errors -#[derive(Debug, thiserror::Error)] -pub enum BitrotErrorType { - #[error("bitrot checksum verification failed")] - BitrotChecksumMismatch { expected: String, got: String }, -} - -impl From for DiskError { - fn from(e: BitrotErrorType) -> Self { - DiskError::other(e) - } -} - /// Context wrapper for file access errors #[derive(Debug, thiserror::Error)] pub struct FileAccessDeniedWithContext { @@ -869,19 +862,6 @@ mod tests { let _disk_error: DiskError = json_error.into(); } - #[test] - fn test_bitrot_error_type() { - let bitrot_error = BitrotErrorType::BitrotChecksumMismatch { - expected: "abc123".to_string(), - got: "def456".to_string(), - }; - - assert!(bitrot_error.to_string().contains("bitrot checksum verification failed")); - - let disk_error: DiskError = bitrot_error.into(); - assert!(matches!(disk_error, DiskError::Io(_))); - } - #[test] fn test_file_access_denied_with_context() { let path = PathBuf::from("/test/path");