fix(lifecycle): Return NoSuchLifecycleConfiguration error for missing lifecycle config (#1087)

Co-authored-by: loverustfs <hello@rustfs.com>
This commit is contained in:
tennisleng
2025-12-09 23:35:22 -05:00
committed by GitHub
parent ae46ea4bd3
commit ac0c34e734

View File

@@ -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()
}))
}