rustfs/rustfs · error · Error::NoSuchUser

user '{0}' does not exist

Error message

user '{0}' does not exist

What it means

Error::NoSuchUser(String) (crates/iam/src/error.rs:35) is the IAM layer's 404-class miss for a named user/access key: returned when a user record lookup fails in the IAM store — manager.rs:741/1257/1549-1682/2546-2570 (credential lookup, status change, group membership ops) and store/object.rs identity-file misses (607-642/923/1329). The Display embeds the access key that was not found. sys.rs:551/561 also returns it from user-info paths.

Source

Thrown at crates/iam/src/error.rs:35

use std::sync::Arc;

pub type Result<T> = core::result::Result<T, Error>;

#[derive(thiserror::Error, Debug)]
pub enum Error {
    // Arc payloads keep Clone variant-preserving for the non-cloneable inner
    // errors (backlog#1831 PR2). Display is unchanged; the source() chain is
    // not forwarded (Arc<E> does not implement std::error::Error).
    #[error("{0}")]
    PolicyError(Arc<PolicyError>),

    #[error("{0}")]
    StringError(String),

    #[error("crypto: {0}")]
    CryptoError(Arc<rustfs_crypto::Error>),

    #[error("user '{0}' does not exist")]
    NoSuchUser(String),

    #[error("account '{0}' does not exist")]
    NoSuchAccount(String),

    #[error("service account '{0}' does not exist")]
    NoSuchServiceAccount(String),

    #[error("temp account '{0}' does not exist")]
    NoSuchTempAccount(String),

    #[error("group '{0}' does not exist")]
    NoSuchGroup(String),

    #[error("policy does not exist")]
    NoSuchPolicy,

    #[error("policy in use")]

View on GitHub (pinned to 35af688cd9)

Solutions

  1. List current users via the admin IAM API and confirm the exact access key/user name spelling
  2. If the user was deleted, recreate it (admin user add) or update the client to use a valid credential
  3. For group operations, remove the stale member reference before retrying the group mutation
  4. If the store was restored, verify config/iam consistency (users vs group membership files)

Example fix

// before
let creds = manager.get_user_credentials(&access_key).await?; // NoSuchUser bubbles

// after
use rustfs_iam::error::{is_err_no_such_user, Error};
let creds = match manager.get_user_credentials(&access_key).await {
    Err(e) if is_err_no_such_user(&e) => return Err(AuthError::InvalidAccessKey(access_key)), // map to auth failure
    r => r?,
};
Defensive patterns

Strategy: type-guard

Validate before calling

// Before user-targeted operations, confirm the user exists:
// if !admin.user_exists(access_key).await? { return Err(handled_invalid_key(access_key)); }

Type guard

// The crate ships this guard (crates/iam/src/error.rs):
// pub fn is_err_no_such_user(err: &Error) -> bool
if is_err_no_such_user(&e) { /* map to 404/InvalidAccessKey */ }

Try / catch

match manager.get_user_credentials(access_key).await {
    Err(e) if is_err_no_such_user(&e) => Err(AuthError::InvalidAccessKey(access_key.to_string())),
    r => r,
}

Prevention

When it happens

Trigger: Looking up credentials for an access key that has no user record (deleted user, typo'd key, STS-derived key not yet materialized); calling set_user_status / group add / policy detach for a user name absent from the store; deleting group members where one member no longer exists.

Common situations: Client keeps using an access key after the user was deleted or disabled-and-removed; console operations referencing a user renamed or recreated; IAM store partially synced after restore-from-backup; scripts hitting the admin API with stale user names.

Understand the failure class

Background: "User not found", "Invalid user", and "does not exist": what missing-user lookup errors mean across Rocket.Chat, LiteLLM, Phabricator, rustfs, and pnpm — this error's family across 10 libraries.

Related errors


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