Skip to content

Conversation

@weisd
Copy link
Contributor

@weisd weisd commented Nov 10, 2025

Refactor: Simplify bucket policy error handling

Summary

This PR simplifies error handling in policy_sys.rs by directly using StorageError::ConfigNotFound instead of converting through BucketMetadataError. This change reduces unnecessary type conversions and aligns with the unified error handling approach.

Changes

  • Removed BucketMetadataError import and type conversion
  • Changed error check to directly compare with StorageError::ConfigNotFound
  • Updated log level from warn to info for config not found errors
  • Simplified error handling logic in is_allowed method

Code Changes

Before

use super::{error::BucketMetadataError, metadata_sys::get_bucket_metadata_sys};
// ...
Err(err) => {
    let berr: BucketMetadataError = err.into();
    if berr != BucketMetadataError::BucketPolicyNotFound {
        warn!("config get err {:?}", berr);
    }
}

After

use crate::error::{Result, StorageError};
// ...
Err(err) => {
    if err != StorageError::ConfigNotFound {
        info!("config get err {:?}", err);
    }
}

Benefits

  1. Simplified code: Removes unnecessary type conversion step
  2. Consistent error handling: Uses unified StorageError type directly
  3. Reduced complexity: Fewer imports and type conversions
  4. Better log level: Changed from warn to info for expected "not found" scenarios

Related Issues

Fixes #823

@weisd weisd merged commit 5941062 into main Nov 10, 2025
14 checks passed
@weisd weisd deleted the fix/823 branch November 10, 2025 11:23
houseme added a commit that referenced this pull request Nov 11, 2025
…ypto

* 'main' of github.com:rustfs/rustfs:
  wip (#830)
  fix list object err (#831)
  fix (#828)
  feat(storage): refactor audit and notification with OperationHelper (#825)

# Conflicts:
#	Cargo.toml
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Is the content of this logs normal?

1 participant