From ac0c34e73410bbfb97d924ea015a66b94011f677 Mon Sep 17 00:00:00 2001 From: tennisleng <83838474+tennisleng@users.noreply.github.com> Date: Tue, 9 Dec 2025 23:35:22 -0500 Subject: [PATCH] fix(lifecycle): Return NoSuchLifecycleConfiguration error for missing lifecycle config (#1087) Co-authored-by: loverustfs --- rustfs/src/storage/ecfs.rs | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/rustfs/src/storage/ecfs.rs b/rustfs/src/storage/ecfs.rs index be4100b3..de863b78 100644 --- a/rustfs/src/storage/ecfs.rs +++ b/rustfs/src/storage/ecfs.rs @@ -4518,18 +4518,16 @@ impl S3 for FS { .map_err(ApiError::from)?; let rules = match metadata_sys::get_lifecycle_config(&bucket).await { - Ok((cfg, _)) => Some(cfg.rules), + Ok((cfg, _)) => cfg.rules, Err(_err) => { - // if BucketMetadataError::BucketLifecycleNotFound.is(&err) { - // return Err(s3_error!(NoSuchLifecycleConfiguration)); - // } - // warn!("get_lifecycle_config err {:?}", err); - None + // Return NoSuchLifecycleConfiguration error as expected by S3 clients + // This fixes issue #990 where Ansible S3 roles fail with KeyError: 'Rules' + return Err(s3_error!(NoSuchLifecycleConfiguration)); } }; Ok(S3Response::new(GetBucketLifecycleConfigurationOutput { - rules, + rules: Some(rules), ..Default::default() })) }