feat(client): Reject empty open_timeouts configuration with dedicated error

This commit is contained in:
Nils Andreas Svee committed 2026-05-10 20:56:43 +07:00
1 parent 04ebaf829a
commit befe431304
3 files changed
+17

No files matched your search

+12
View File
@@ -791,4 +791,16 @@ mod tests {
Err(ClientError::OpenTimeoutTooSmall { .. })
));
}
#[test]
fn empty_open_timeouts_is_rejected() {
let config = ClientConfig {
open_timeouts: vec![],
..ClientConfig::default()
};
assert!(matches!(
Client::connect(config),
Err(ClientError::NoOpenTimeouts)
));
}
}
+2
View File
@@ -17,6 +17,8 @@ pub enum ClientError {
timeout: Duration,
minimum: Duration,
},
#[error("open_timeouts must not be empty")]
NoOpenTimeouts,
#[error("server rejected the open request")]
ServerRejected,
#[error("unexpected no-test open reply")]
+3
View File
@@ -11,6 +11,9 @@ use crate::{
};
pub(crate) fn validate_open_timeouts(timeouts: &[Duration]) -> Result<(), ClientError> {
if timeouts.is_empty() {
return Err(ClientError::NoOpenTimeouts);
}
for timeout in timeouts {
if *timeout < MIN_OPEN_TIMEOUT {
return Err(ClientError::OpenTimeoutTooSmall {