From b610d5a55dfe11685d046a9d5a073cb34fa180dc Mon Sep 17 00:00:00 2001 From: Zhengchao An Date: Wed, 26 Aug 2026 13:24:36 +0800 Subject: [PATCH] fix(policy): remove six dead error variants (#6631) Backlog#1845 step 8 prerequisite. policy::error::Error carried six variants with zero construction and zero match sites anywhere in the workspace: ErrCredMalformed, CredNotInitialized, NoAccessKey, InvalidToken, InvalidAccessKey, InvalidExpiration. Their only reference was the grouped fallthrough arm in iam's From, whose own dead same-name twins were already removed in backlog#1831 (#6030). Delete the variants and their display-message test rows; the iam mapping's grouped arm shrinks from eight variants to the two that are actually produced (InvalidServiceType from service_type parsing, JWTError via #[from]). This clears the way for folding the remaining 25-arm hand-written mapping (backlog#1845 step 8). Ref rustfs/backlog#1845 --- crates/iam/src/error.rs | 14 +++++--------- crates/policy/src/error.rs | 24 ------------------------ 2 files changed, 5 insertions(+), 33 deletions(-) diff --git a/crates/iam/src/error.rs b/crates/iam/src/error.rs index f4cf809c9..a1220db62 100644 --- a/crates/iam/src/error.rs +++ b/crates/iam/src/error.rs @@ -214,15 +214,11 @@ impl From for Error { rustfs_policy::error::Error::IamSysAlreadyInitialized => Error::IamSysAlreadyInitialized, // These policy variants had dead same-name twins on iam::Error (zero // construction and zero match sites, removed in backlog#1831); the - // message is preserved through StringError instead. - err @ (rustfs_policy::error::Error::InvalidServiceType(_) - | rustfs_policy::error::Error::InvalidExpiration - | rustfs_policy::error::Error::NoAccessKey - | rustfs_policy::error::Error::InvalidToken - | rustfs_policy::error::Error::InvalidAccessKey - | rustfs_policy::error::Error::JWTError(_) - | rustfs_policy::error::Error::CredNotInitialized - | rustfs_policy::error::Error::ErrCredMalformed) => Error::StringError(err.to_string()), + // message is preserved through StringError instead. Their six dead + // siblings on policy::Error were deleted outright (backlog#1845). + err @ (rustfs_policy::error::Error::InvalidServiceType(_) | rustfs_policy::error::Error::JWTError(_)) => { + Error::StringError(err.to_string()) + } } } } diff --git a/crates/policy/src/error.rs b/crates/policy/src/error.rs index 3963234bd..23c9baa44 100644 --- a/crates/policy/src/error.rs +++ b/crates/policy/src/error.rs @@ -60,12 +60,6 @@ pub enum Error { #[error("invalid service type: {0}")] InvalidServiceType(String), - #[error("malformed credential")] - ErrCredMalformed, - - #[error("CredNotInitialized")] - CredNotInitialized, - #[error("invalid access key length")] InvalidAccessKeyLength, @@ -81,21 +75,9 @@ pub enum Error { #[error("jwt err {0}")] JWTError(#[from] jsonwebtoken::errors::Error), - #[error("no access key")] - NoAccessKey, - - #[error("invalid token")] - InvalidToken, - - #[error("invalid access_key")] - InvalidAccessKey, - #[error("action not allowed")] IAMActionNotAllowed, - #[error("invalid expiration")] - InvalidExpiration, - #[error("no secret key with access key")] NoSecretKeyWithAccessKey, @@ -343,17 +325,11 @@ mod tests { (Error::InvalidArgument, "invalid arguments specified"), (Error::IamSysNotInitialized, "not initialized"), (Error::InvalidServiceType("invalid".to_string()), "invalid service type: invalid"), - (Error::ErrCredMalformed, "malformed credential"), - (Error::CredNotInitialized, "CredNotInitialized"), (Error::InvalidAccessKeyLength, "invalid access key length"), (Error::InvalidSecretKeyLength, "invalid secret key length"), (Error::ContainsReservedChars, "access key contains reserved characters =,"), (Error::GroupNameContainsReservedChars, "group name contains reserved characters =,"), - (Error::NoAccessKey, "no access key"), - (Error::InvalidToken, "invalid token"), - (Error::InvalidAccessKey, "invalid access_key"), (Error::IAMActionNotAllowed, "action not allowed"), - (Error::InvalidExpiration, "invalid expiration"), (Error::NoSecretKeyWithAccessKey, "no secret key with access key"), (Error::NoAccessKeyWithSecretKey, "no access key with secret key"), (Error::PolicyTooLarge, "policy too large"),