From 6f64099a4897cbd7044805f5832ecf1155178aba Mon Sep 17 00:00:00 2001 From: fettpl <38704082+fettpl@users.noreply.github.com> Date: Sun, 15 Feb 2026 01:29:23 +0100 Subject: [PATCH] fix: replace unstable is_multiple_of with modulo and fix flaky temp test The `is_multiple_of` method is unstable before Rust 1.87, breaking Docker builds that use rust:1.83-slim. Also merges the two temperature env-var tests into one to eliminate the race condition when tests run in parallel. Co-Authored-By: Claude Opus 4.6 --- src/config/schema.rs | 21 +++++++++------------ src/security/secrets.rs | 2 +- 2 files changed, 10 insertions(+), 13 deletions(-) diff --git a/src/config/schema.rs b/src/config/schema.rs index be6f768..3ef7c42 100644 --- a/src/config/schema.rs +++ b/src/config/schema.rs @@ -1613,26 +1613,23 @@ default_temperature = 0.7 #[test] fn env_override_temperature() { + // Both temperature cases tested in one function to avoid env-var + // races when tests run in parallel. std::env::remove_var("ZEROCLAW_TEMPERATURE"); - let mut config = Config::default(); + // Valid temperature is applied + let mut config = Config::default(); std::env::set_var("ZEROCLAW_TEMPERATURE", "0.5"); config.apply_env_overrides(); assert!((config.default_temperature - 0.5).abs() < f64::EPSILON); - std::env::remove_var("ZEROCLAW_TEMPERATURE"); - } - - #[test] - fn env_override_temperature_out_of_range_ignored() { - std::env::remove_var("ZEROCLAW_TEMPERATURE"); - let mut config = Config::default(); - let original_temp = config.default_temperature; - + // Out-of-range temperature is ignored + let mut config2 = Config::default(); + let original_temp = config2.default_temperature; std::env::set_var("ZEROCLAW_TEMPERATURE", "3.0"); - config.apply_env_overrides(); + config2.apply_env_overrides(); assert!( - (config.default_temperature - original_temp).abs() < f64::EPSILON, + (config2.default_temperature - original_temp).abs() < f64::EPSILON, "Temperature 3.0 should be ignored (out of range)" ); diff --git a/src/security/secrets.rs b/src/security/secrets.rs index 38a8d6a..8dea343 100644 --- a/src/security/secrets.rs +++ b/src/security/secrets.rs @@ -242,7 +242,7 @@ fn hex_encode(data: &[u8]) -> String { /// Hex-decode a hex string to bytes. #[allow(clippy::manual_is_multiple_of)] fn hex_decode(hex: &str) -> Result> { - if !hex.len().is_multiple_of(2) { + if hex.len() % 2 != 0 { anyhow::bail!("Hex string has odd length"); } (0..hex.len())