cpex_session_valkey/error.rs
1// Location: ./builtins/session/valkey/src/error.rs
2// Copyright 2026
3// SPDX-License-Identifier: Apache-2.0
4// Authors: Fred Araujo
5//
6// Construction-time errors for the Valkey session-store backend. These
7// surface when the `global.apl.session_store` config block is malformed
8// or the connection pool cannot be built — i.e. at `load_config_yaml`
9// time, NOT on the request hot path. Request-time failures flow through
10// `apl_cpex::SessionStoreError` (the trait's return type) so callers can
11// fail closed.
12
13/// Error returned while building a `ValkeySessionStore` from config.
14#[derive(Debug, thiserror::Error)]
15pub enum BuildError {
16 /// The config block was structurally invalid (missing/!typed fields).
17 #[error("invalid valkey session_store config: {0}")]
18 Config(String),
19
20 /// TLS is mandatory for any non-localhost endpoint: session
21 /// security labels must not transit a network segment in plaintext.
22 #[error(
23 "valkey session_store requires TLS for non-localhost endpoint '{0}' \
24 — set `tls: true` or use a `rediss://` URL"
25 )]
26 TlsRequired(String),
27
28 /// The connection pool could not be constructed (bad URL, etc.).
29 #[error("failed to build valkey connection pool: {0}")]
30 Pool(String),
31}