OpenAgentID documentation
Source referencesRust module referencearsenal-core

arsenal-core · error

Declared module signatures, types, configuration, and source documentation.

Source: arsenal/crates/arsenal-core/src/error.rs. SHA-256: 8bdb49267bc6aecdbc280e3249509568c2de55bf309da38e91d5aef60c209130.

This source reference follows declared modules and preserves feature attributes. It includes public declarations and implementation methods in those modules. Private-module exports and trait resolution still require the compiler; not every declaration is a crate-root import. Function bodies and constant values are omitted. Source comments describe their implementation context and are not a production deployment claim.

error::ArsenalResult

Result type alias for ARSENAL operations

pub type ArsenalResult<T> = Result<T, ArsenalError>;

Source line: 14.

error::ErrorCode

Error codes for programmatic handling

#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Serialize, Deserialize)]
#[serde(rename_all = "SCREAMING_SNAKE_CASE")]
pub enum ErrorCode {
    // Authentication errors (1xxx)
    /// Invalid or missing credentials
    AuthenticationFailed = 1001,
    /// Token expired
    TokenExpired = 1002,
    /// Token signature verification failed
    TokenSignatureInvalid = 1003,
    /// Proof-of-possession verification failed
    PopVerificationFailed = 1004,
    /// Identity not found or invalid
    IdentityInvalid = 1005,
    /// Session has expired or been revoked
    SessionExpired = 1006,

    // Authorization errors (2xxx)
    /// Insufficient permissions for requested operation
    InsufficientPermissions = 2001,
    /// Requested scope exceeds granted scope
    ScopeExceeded = 2002,
    /// Policy evaluation denied the request
    PolicyDenied = 2003,
    /// Delegation chain is invalid or broken
    DelegationInvalid = 2004,
    /// Rate limit exceeded
    RateLimitExceeded = 2005,
    /// Usage budget exhausted
    BudgetExhausted = 2006,

    // Constraint violations (3xxx)
    /// Request violates time-based constraints
    TimeConstraintViolation = 3001,
    /// Request violates environment binding
    EnvironmentBindingViolation = 3002,
    /// Request violates IP/network constraints
    NetworkConstraintViolation = 3003,
    /// Request violates device binding
    DeviceBindingViolation = 3004,
    /// Request violates origin binding
    OriginBindingViolation = 3005,

    // Secret management errors (4xxx)
    /// Secret not found
    SecretNotFound = 4001,
    /// Secret version not found
    SecretVersionNotFound = 4002,
    /// Secret has been revoked
    SecretRevoked = 4003,
    /// Secret rotation in progress
    SecretRotationInProgress = 4004,
    /// Secret unwrap limit exceeded
    SecretUnwrapLimitExceeded = 4005,
    /// Encryption/decryption failed
    CryptoOperationFailed = 4006,

    // Validation errors (5xxx)
    /// Input validation failed
    ValidationFailed = 5001,
    /// Malformed request
    MalformedRequest = 5002,
    /// Invalid token format
    InvalidTokenFormat = 5003,
    /// Invalid scope format
    InvalidScopeFormat = 5004,
    /// Invalid constraint specification
    InvalidConstraint = 5005,

    // Internal errors (6xxx)
    /// Internal service error
    InternalError = 6001,
    /// Storage backend error
    StorageError = 6002,
    /// Configuration error
    ConfigurationError = 6003,
    /// Cryptographic subsystem error
    CryptoSubsystemError = 6004,
    /// Audit subsystem error
    AuditError = 6005,
    /// Serialization failed
    SerializationFailed = 6006,

    // Revocation errors (7xxx)
    /// Token has been explicitly revoked
    TokenRevoked = 7001,
    /// Agent has been deactivated
    AgentDeactivated = 7002,
    /// Tenant has been suspended
    TenantSuspended = 7003,
    /// Revocation status could not be determined (fail-closed policy path)
    RevocationStatusUnknown = 7004,

    // Proxy errors (8xxx)
    /// Request violates destination binding for the credential
    ProxyDestinationViolation = 8001,
    /// Proxy request to target API failed
    ProxyRequestFailed = 8002,
    /// Proxy request timed out
    ProxyTimeout = 8003,
    /// Request blocked by SSRF protection
    SsrfBlocked = 8004,
    /// Referenced template variable not found in resolution table
    TemplateVariableNotFound = 8005,
    /// Agent does not have permission to access the template variable
    TemplateVariableAccessDenied = 8006,
    /// Template variable name is malformed
    InvalidTemplateVariable = 8007,
    /// OAuth token requires re-authentication
    OAuthReauthRequired = 8008,

    // Consent errors (9xxx)
    /// Human consent is required before accessing the credential
    ConsentRequired = 9001,
    /// Consent was explicitly denied
    ConsentDenied = 9002,
    /// Consent record has expired
    ConsentExpired = 9003,
    /// Consent was previously granted but has been revoked
    ConsentRevoked = 9004,

    // Fingerprint errors (10xxx)
    /// Agent fingerprint does not match expected hash chain state
    FingerprintMismatch = 10001,
    /// Agent fingerprint state not found (agent not initialized)
    FingerprintStateNotFound = 10002,

    // Delegation errors (11xxx)
    /// Delegated credential token attempts scope amplification
    DctScopeAmplification = 11001,
    /// Delegation depth exceeds maximum allowed
    DctDepthExceeded = 11002,
}

Source line: 19.

error::ErrorCode::as_u32

Returns the numeric code

#[must_use]
pub const fn as_u32(self) -> u32;

Source line: 154.

error::ErrorCode::is_client_error

Returns true if this is a client error (retrying won't help)

#[must_use]
pub const fn is_client_error(self) -> bool;

Source line: 160.

error::ErrorCode::is_server_error

Returns true if this is a server error (may be transient)

#[must_use]
pub const fn is_server_error(self) -> bool;

Source line: 167.

error::ErrorCode::is_proxy_error

Returns true if this is a proxy-related error

#[must_use]
pub const fn is_proxy_error(self) -> bool;

Source line: 174.

Returns true if this is a consent-related error

#[must_use]
pub const fn is_consent_error(self) -> bool;

Source line: 181.

error::ErrorCode::is_fingerprint_error

Returns true if this is a fingerprint-related error

#[must_use]
pub const fn is_fingerprint_error(self) -> bool;

Source line: 188.

error::ErrorCode::is_permanent

Returns true if the error indicates the request should not be retried

#[must_use]
pub const fn is_permanent(self) -> bool;

Source line: 195.

error::ArsenalError

Main error type for ARSENAL operations

#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct ArsenalError {

}

Source line: 213.

error::ErrorContext

Additional error context (all fields are sanitized)

#[derive(Debug, Clone, Default, Serialize, Deserialize)]
pub struct ErrorContext {
/// The operation that failed

#[serde(skip_serializing_if = "Option::is_none")]
pub operation: Option<String>,
/// Resource identifier (sanitized - no full paths or keys)

#[serde(skip_serializing_if = "Option::is_none")]
pub resource: Option<String>,
/// Constraint that was violated

#[serde(skip_serializing_if = "Option::is_none")]
pub constraint: Option<String>,
/// Timestamp of the error

#[serde(skip_serializing_if = "Option::is_none")]
pub timestamp: Option<chrono::DateTime<chrono::Utc>>
}

Source line: 228.

error::ArsenalError::new

Create a new error with the given code and message

#[must_use]
pub fn new(code: ErrorCode, message: impl Into<String>) -> Self;

Source line: 246.

error::ArsenalError::with_correlation_id

Add a correlation ID for audit trail

#[must_use]
pub fn with_correlation_id(mut self, id: Uuid) -> Self;

Source line: 257.

error::ArsenalError::with_context

Add context to the error

#[must_use]
pub fn with_context(mut self, context: ErrorContext) -> Self;

Source line: 264.

error::ArsenalError::with_operation

Add operation context

#[must_use]
pub fn with_operation(mut self, operation: impl Into<String>) -> Self;

Source line: 271.

error::ArsenalError::with_resource

Add resource context (will be sanitized)

#[must_use]
pub fn with_resource(mut self, resource: impl Into<String>) -> Self;

Source line: 279.

error::ArsenalError::code

Get the error code

#[must_use]
pub const fn code(&self) -> ErrorCode;

Source line: 288.

error::ArsenalError::message

Get the error message

#[must_use]
pub fn message(&self) -> &str;

Source line: 294.

error::ArsenalError::correlation_id

Get the correlation ID if set

#[must_use]
pub const fn correlation_id(&self) -> Option<Uuid>;

Source line: 300.

error::ArsenalError::context

Get the error context if set

#[must_use]
pub fn context(&self) -> Option<&ErrorContext>;

Source line: 306.

error::ArsenalError::authentication_failed

Authentication failed

#[must_use]
pub fn authentication_failed() -> Self;

Source line: 314.

error::ArsenalError::token_expired

Token expired

#[must_use]
pub fn token_expired() -> Self;

Source line: 320.

error::ArsenalError::token_signature_invalid

Token signature invalid

#[must_use]
pub fn token_signature_invalid() -> Self;

Source line: 326.

error::ArsenalError::pop_verification_failed

Proof-of-possession failed

#[must_use]
pub fn pop_verification_failed() -> Self;

Source line: 335.

error::ArsenalError::insufficient_permissions

Insufficient permissions

#[must_use]
pub fn insufficient_permissions(required_scope: &str) -> Self;

Source line: 344.

error::ArsenalError::scope_exceeded

Scope exceeded

#[must_use]
pub fn scope_exceeded() -> Self;

Source line: 356.

error::ArsenalError::policy_denied

Policy denied

#[must_use]
pub fn policy_denied(policy_id: &str) -> Self;

Source line: 365.

error::ArsenalError::rate_limit_exceeded

Rate limit exceeded

#[must_use]
pub fn rate_limit_exceeded(retry_after_secs: Option<u64>) -> Self;

Source line: 377.

error::ArsenalError::secret_not_found

Secret not found

#[must_use]
pub fn secret_not_found() -> Self;

Source line: 387.

error::ArsenalError::secret_revoked

Secret revoked

#[must_use]
pub fn secret_revoked() -> Self;

Source line: 393.

error::ArsenalError::validation_failed

Validation failed

#[must_use]
pub fn validation_failed(field: &str, reason: &str) -> Self;

Source line: 399.

error::ArsenalError::internal

Internal error (generic, no details leaked)

#[must_use]
pub fn internal() -> Self;

Source line: 412.

error::ArsenalError::token_revoked

Token revoked

#[must_use]
pub fn token_revoked() -> Self;

Source line: 421.

error::ArsenalError::revocation_status_unknown

Revocation status could not be determined (fail-closed)

#[must_use]
pub fn revocation_status_unknown() -> Self;

Source line: 427.

error::ArsenalError::session_expired

Session expired

#[must_use]
pub fn session_expired() -> Self;

Source line: 436.

error::ArsenalError::proxy_destination_violation

Proxy destination binding violation

#[must_use]
pub fn proxy_destination_violation(domain: &str) -> Self;

Source line: 445.

error::ArsenalError::proxy_request_failed

Proxy request to target failed

#[must_use]
pub fn proxy_request_failed(status: u16) -> Self;

Source line: 457.

error::ArsenalError::ssrf_blocked

SSRF protection blocked the request

#[must_use]
pub fn ssrf_blocked() -> Self;

Source line: 466.

error::ArsenalError::template_variable_not_found

Template variable not found

#[must_use]
pub fn template_variable_not_found(variable: &str) -> Self;

Source line: 475.

error::ArsenalError::template_variable_access_denied

Template variable access denied

#[must_use]
pub fn template_variable_access_denied(variable: &str) -> Self;

Source line: 487.

error::ArsenalError::invalid_template_variable

Invalid template variable name

#[must_use]
pub fn invalid_template_variable(name: &str) -> Self;

Source line: 499.

error::ArsenalError::oauth_reauth_required

OAuth re-authentication required

#[must_use]
pub fn oauth_reauth_required() -> Self;

Source line: 508.

error::ArsenalError::consent_required

Consent required

#[must_use]
pub fn consent_required() -> Self;

Source line: 517.

error::ArsenalError::consent_denied

Consent denied

#[must_use]
pub fn consent_denied() -> Self;

Source line: 526.

error::ArsenalError::consent_expired

Consent expired

#[must_use]
pub fn consent_expired() -> Self;

Source line: 535.

error::ArsenalError::consent_revoked

Consent revoked

#[must_use]
pub fn consent_revoked() -> Self;

Source line: 541.

error::ArsenalError::fingerprint_mismatch

Fingerprint mismatch — potential key theft

#[must_use]
pub fn fingerprint_mismatch() -> Self;

Source line: 550.

error::ArsenalError::fingerprint_state_not_found

Fingerprint state not found

#[must_use]
pub fn fingerprint_state_not_found() -> Self;

Source line: 559.

error::ArsenalError::dct_scope_amplification

DCT scope amplification attempt

#[must_use]
pub fn dct_scope_amplification(variable: &str) -> Self;

Source line: 568.

error::ArsenalError::dct_depth_exceeded

DCT depth exceeded

#[must_use]
pub fn dct_depth_exceeded() -> Self;

Source line: 580.

error::ArsenalError::crypto_operation_failed

Crypto operation failed (generic message to avoid oracle attacks)

#[must_use]
pub fn crypto_operation_failed() -> Self;

Source line: 589.

error::ArsenalError::storage_error

Storage error (generic message)

#[must_use]
pub fn storage_error() -> Self;

Source line: 598.

error::ArsenalError::configuration_error

Configuration error

#[must_use]
pub fn configuration_error(component: &str) -> Self;

Source line: 604.

error::ArsenalError::invalid_state_transition

Invalid state transition

#[must_use]
pub fn invalid_state_transition(from: impl Into<String>, to: impl Into<String>) -> Self;

Source line: 616.

On this page

error::ArsenalResulterror::ErrorCodeerror::ErrorCode::as_u32error::ErrorCode::is_client_errorerror::ErrorCode::is_server_errorerror::ErrorCode::is_proxy_errorerror::ErrorCode::is_consent_errorerror::ErrorCode::is_fingerprint_errorerror::ErrorCode::is_permanenterror::ArsenalErrorerror::ErrorContexterror::ArsenalError::newerror::ArsenalError::with_correlation_iderror::ArsenalError::with_contexterror::ArsenalError::with_operationerror::ArsenalError::with_resourceerror::ArsenalError::codeerror::ArsenalError::messageerror::ArsenalError::correlation_iderror::ArsenalError::contexterror::ArsenalError::authentication_failederror::ArsenalError::token_expirederror::ArsenalError::token_signature_invaliderror::ArsenalError::pop_verification_failederror::ArsenalError::insufficient_permissionserror::ArsenalError::scope_exceedederror::ArsenalError::policy_deniederror::ArsenalError::rate_limit_exceedederror::ArsenalError::secret_not_founderror::ArsenalError::secret_revokederror::ArsenalError::validation_failederror::ArsenalError::internalerror::ArsenalError::token_revokederror::ArsenalError::revocation_status_unknownerror::ArsenalError::session_expirederror::ArsenalError::proxy_destination_violationerror::ArsenalError::proxy_request_failederror::ArsenalError::ssrf_blockederror::ArsenalError::template_variable_not_founderror::ArsenalError::template_variable_access_deniederror::ArsenalError::invalid_template_variableerror::ArsenalError::oauth_reauth_requirederror::ArsenalError::consent_requirederror::ArsenalError::consent_deniederror::ArsenalError::consent_expirederror::ArsenalError::consent_revokederror::ArsenalError::fingerprint_mismatcherror::ArsenalError::fingerprint_state_not_founderror::ArsenalError::dct_scope_amplificationerror::ArsenalError::dct_depth_exceedederror::ArsenalError::crypto_operation_failederror::ArsenalError::storage_errorerror::ArsenalError::configuration_errorerror::ArsenalError::invalid_state_transition