rustfs/rustfs · error · KmsError::KeyAlreadyExists

Key already exists: {key_id}

Error message

Key already exists: {key_id}

What it means

KmsError guard meaning key creation was refused because a key with the same key_id already exists in the backend. It enforces create-idempotency semantics (distinct from overwrite): callers surface 'already exists' to the admin API instead of silently rotating the existing key; the key id is embedded in the message.

Source

Thrown at crates/kms/src/error.rs:55

    /// Invalid key format or content
    #[error("Invalid key: {message}")]
    InvalidKey { message: String },

    /// Cryptographic operation failed
    #[error("Cryptographic error in {operation}: {message}")]
    CryptographicError { operation: String, message: String },

    /// Backend communication error
    #[error("Backend error: {message}")]
    BackendError { message: String },

    /// Access denied
    #[error("Access denied: {message}")]
    AccessDenied { message: String },

    /// Key already exists
    #[error("Key already exists: {key_id}")]
    KeyAlreadyExists { key_id: String },

    /// Invalid operation state
    #[error("Invalid operation: {message}")]
    InvalidOperation { message: String },

    /// Internal error
    #[error("Internal error: {message}")]
    InternalError { message: String },

    /// Serialization/deserialization error
    #[error("Serialization error: {message}")]
    SerializationError { message: String },

    /// I/O error
    #[error("I/O error: {message}")]
    IoError { message: String },

View on GitHub (pinned to 35af688cd9)

Solutions

  1. Use the existing key instead of creating a new one
  2. Pick a different key_id for the new key
  3. Delete the existing key first if replacement is intentional (data encrypted with it becomes unreadable)
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at crates/kms/src/error.rs:55 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of rustfs/rustfs@35af688cd9 (2026-08-20). Data as JSON: /api/errors/1db66eb2f45e9593. Report an issue: GitHub.