From 68f445b3aa4bca6a80557130146777cb3683fc3e Mon Sep 17 00:00:00 2001 From: Hugh Brown Date: Mon, 9 Mar 2026 00:21:31 -0600 Subject: [PATCH 1/3] fix: propagate TLS errors, fix changelog link, deduplicate query parsing - Replace .unwrap() on native_tls::TlsConnector::new() with .migration_err() in both with_connection! and with_connection_async! macros to propagate errors instead of panicking - Fix CHANGELOG.md PR #403 link URL (was pointing to #401) - Collect URL query params once before struct initialization in TryFrom for Config, avoiding redundant parsing for use_tls and trust_cert fields Co-Authored-By: Claude Opus 4.6 --- CHANGELOG.md | 2 +- refinery_core/src/config.rs | 18 ++++++++++-------- refinery_core/src/drivers/config.rs | 4 ++-- 3 files changed, 13 insertions(+), 11 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index f88530e2..4e6a6bd4 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -16,7 +16,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Update `rusqlite` to support up until version 0.37. [#389](https://github.com/rust-db/refinery/pull/389), [#390](https://github.com/rust-db/refinery/pull/390) - Update `thiserror` to version 2. [#372](https://github.com/rust-db/refinery/pull/372) - Update MSRV (Minimum Supported Rust Version). [#401](https://github.com/rust-db/refinery/pull/401), [#362](https://github.com/rust-db/refinery/pull/362) -- Fix unused warnings [#403](https://github.com/rust-db/refinery/pull/401) +- Fix unused warnings [#403](https://github.com/rust-db/refinery/pull/403) ### Fixed diff --git a/refinery_core/src/config.rs b/refinery_core/src/config.rs index ca1b0101..3dc0dccf 100644 --- a/refinery_core/src/config.rs +++ b/refinery_core/src/config.rs @@ -222,6 +222,14 @@ impl TryFrom for Config { } }; + #[cfg(any( + feature = "postgres", + feature = "tokio-postgres", + feature = "tiberius-config" + ))] + let query_params: std::collections::HashMap, Cow<'_, str>> = + url.query_pairs().collect(); + Ok(Self { main: Main { db_type, @@ -274,11 +282,7 @@ impl TryFrom for Config { ))] db_name: Some(url.path().trim_start_matches('/').to_string()), #[cfg(any(feature = "postgres", feature = "tokio-postgres"))] - use_tls: match url - .query_pairs() - .collect::, Cow<'_, str>>>() - .get("sslmode") - { + use_tls: match query_params.get("sslmode") { Some(Cow::Borrowed("require")) => true, Some(Cow::Borrowed("disable")) | None => false, _ => { @@ -291,9 +295,7 @@ impl TryFrom for Config { } }, #[cfg(feature = "tiberius-config")] - trust_cert: url - .query_pairs() - .collect::, Cow<'_, str>>>() + trust_cert: query_params .get("trust_cert") .unwrap_or(&Cow::Borrowed("false")) .parse::() diff --git a/refinery_core/src/drivers/config.rs b/refinery_core/src/drivers/config.rs index 3f1cfd74..1093a6ce 100644 --- a/refinery_core/src/drivers/config.rs +++ b/refinery_core/src/drivers/config.rs @@ -96,7 +96,7 @@ macro_rules! with_connection { let conn; if $config.use_tls() { - let connector = native_tls::TlsConnector::new().unwrap(); + let connector = native_tls::TlsConnector::new().migration_err("could not create TLS connector", None)?; let connector = postgres_native_tls::MakeTlsConnector::new(connector); conn = postgres::Client::connect(path.as_str(), connector).migration_err("could not connect to database", None)?; } else { @@ -144,7 +144,7 @@ macro_rules! with_connection_async { if #[cfg(feature = "tokio-postgres")] { let path = crate::config::build_db_url("postgresql", $config); if $config.use_tls() { - let connector = native_tls::TlsConnector::new().unwrap(); + let connector = native_tls::TlsConnector::new().migration_err("could not create TLS connector", None)?; let connector = postgres_native_tls::MakeTlsConnector::new(connector); let (client, connection) = tokio_postgres::connect(path.as_str(), connector).await.migration_err("could not connect to database", None)?; tokio::spawn(async move { From 4042d48abc6093e263a420452ac5c0557cf36923 Mon Sep 17 00:00:00 2001 From: Hugh Brown Date: Mon, 9 Mar 2026 00:52:52 -0600 Subject: [PATCH 2/3] Upgrade time to 0.3.47 or later (cargo audit) --- Cargo.lock | 14 +++++++------- refinery/Cargo.toml | 2 +- refinery_core/Cargo.toml | 2 +- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index d367c545..66dbaa83 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2042,30 +2042,30 @@ dependencies = [ [[package]] name = "time" -version = "0.3.44" +version = "0.3.47" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "91e7d9e3bb61134e77bde20dd4825b97c010155709965fedf0f49bb138e52a9d" +checksum = "743bd48c283afc0388f9b8827b976905fb217ad9e647fae3a379a9283c4def2c" dependencies = [ "deranged", "itoa", "num-conv", "powerfmt", - "serde", + "serde_core", "time-core", "time-macros", ] [[package]] name = "time-core" -version = "0.1.6" +version = "0.1.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "40868e7c1d2f0b8d73e4a8c7f0ff63af4f6d19be117e90bd73eb1d62cf831c6b" +checksum = "7694e1cfe791f8d31026952abf09c69ca6f6fa4e1a1229e18988f06a04a12dca" [[package]] name = "time-macros" -version = "0.2.24" +version = "0.2.27" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "30cfb0125f12d9c277f35663a0a33f8c30190f4e4574868a330595412d34ebf3" +checksum = "2e70e4c5a0e0a8a4823ad65dfe1a6930e4f4d756dcd9dd7939022b5e8c501215" dependencies = [ "num-conv", "time-core", diff --git a/refinery/Cargo.toml b/refinery/Cargo.toml index f55f0c60..4c30950b 100644 --- a/refinery/Cargo.toml +++ b/refinery/Cargo.toml @@ -36,6 +36,6 @@ futures = "0.3" assert_cmd = "2.0" predicates = "3" tempfile = "3" -time = "0.3.5" +time = "0.3.47" tokio-util = { version = "0.7.7", features = ["compat"] } tokio = { version = "1.9.0", features = ["full"] } diff --git a/refinery_core/Cargo.toml b/refinery_core/Cargo.toml index 7691ae69..4ea19354 100644 --- a/refinery_core/Cargo.toml +++ b/refinery_core/Cargo.toml @@ -42,7 +42,7 @@ tiberius = { version = ">= 0.7, <= 0.12", optional = true, default-features = fa tokio = { version = "1.0", optional = true } futures = { version = "0.3.16", optional = true, features = ["async-await"] } tokio-util = { version = "0.7.7", features = ["compat"], optional = true } -time = { version = "0.3.5", features = ["parsing", "formatting"] } +time = { version = "0.3.47", features = ["parsing", "formatting"] } serde = { version = "1", features = ["derive"], optional = true } toml = { version = "0.8.8", optional = true } From f394a3c90f42f965cb3c9f01f5fbc8d789ce5807 Mon Sep 17 00:00:00 2001 From: Hugh Brown Date: Mon, 9 Mar 2026 01:09:11 -0600 Subject: [PATCH 3/3] Upgrade bytes to 1.11.1 or later for overflow error --- Cargo.lock | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 66dbaa83..ac6f1377 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -221,9 +221,9 @@ checksum = "1fd0f2584146f6f2ef48085050886acf353beff7305ebd1ae69500e27c67f64b" [[package]] name = "bytes" -version = "1.10.1" +version = "1.11.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d71b6127be86fdcfddb610f7182ac57211d4b18a3e9c82eb2d17662f2227ad6a" +checksum = "1e748733b7cbc798e1434b6ac524f0c1ff2ab456fe201501e6497c8417a4fc33" [[package]] name = "cc"