mirror of
https://github.com/rustfs/rustfs.git
synced 2026-08-28 19:24:58 +08:00
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<policy::error::Error>, 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
This commit is contained in:
@@ -214,15 +214,11 @@ impl From<rustfs_policy::error::Error> 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())
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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"),
|
||||
|
||||
Reference in New Issue
Block a user