Skip to content

Open source, composable payments platform | PCI compliant | SaaS and Self-host options | Enables connectivity to multiple payment, payout, fraud, vault and tokenization providers | Uplifts authorization with intelligent routing and revenue recovery | Reduce payment processing costs with cost observability | Reduces payment ops with reconciliation

build: bump MSRV to 1.76.0 (#5586)

Sanchith Hegde59b36a054cfd
diff --git a/.cargo/config.toml b/.cargo/config.toml
deleted file mode 100644
index e643b41ec0..0000000000
--- a/.cargo/config.toml
+++ /dev/null
@@ -1,29 +0,0 @@
-[target.'cfg(all())']
-rustflags = [
- "-Funsafe_code",
- "-Aclippy::option_map_unit_fn",
- "-Wclippy::as_conversions",
- "-Wclippy::expect_used",
- "-Wclippy::index_refutable_slice",
- "-Wclippy::indexing_slicing",
- "-Wclippy::large_futures",
- "-Wclippy::match_on_vec_items",
- "-Wclippy::missing_panics_doc",
- "-Wclippy::out_of_bounds_indexing",
- "-Wclippy::panic",
- "-Wclippy::panic_in_result_fn",
- "-Wclippy::panicking_unwrap",
- "-Wclippy::todo",
- "-Wclippy::unimplemented",
- "-Wclippy::unreachable",
- "-Wclippy::unwrap_in_result",
- "-Wclippy::unwrap_used",
- "-Wclippy::use_self",
- # "-Wmissing_debug_implementations",
- # "-Wmissing_docs",
- "-Wrust_2018_idioms",
- "-Wunused_qualifications",
-]
-
-[alias]
-gen-pg = "generate --path ../../../../connector-template -n"
diff --git a/.deepsource.toml b/.deepsource.toml
index 640298afbd..49f6f55488 100644
--- a/.deepsource.toml
+++ b/.deepsource.toml
@@ -13,4 +13,4 @@ name = "rust"
enabled = true
[analyzers.meta]
-msrv = "1.70.0"
+msrv = "1.76.0"
diff --git a/.github/workflows/CI-pr.yml b/.github/workflows/CI-pr.yml
index c4314c522f..c94751b989 100644
--- a/.github/workflows/CI-pr.yml
+++ b/.github/workflows/CI-pr.yml
@@ -91,6 +91,7 @@ jobs:
env:
# Use `sccache` for caching compilation artifacts
RUSTC_WRAPPER: sccache
+ RUSTFLAGS: "-D warnings"
strategy:
fail-fast: false
@@ -142,10 +143,6 @@ jobs:
shell: bash
run: .github/scripts/install-jq.sh
- - name: Deny warnings
- shell: bash
- run: sed -i 's/rustflags = \[/rustflags = \[\n "-Dwarnings",/' .cargo/config.toml
-
- name: Cargo hack
shell: bash
env:
@@ -180,6 +177,7 @@ jobs:
env:
# Use `sccache` for caching compilation artifacts
RUSTC_WRAPPER: sccache
+ RUSTFLAGS: "-D warnings"
strategy:
fail-fast: false
@@ -249,16 +247,6 @@ jobs:
# tool: cargo-nextest
# checksum: true
- # - name: Setup Embark Studios lint rules
- # shell: bash
- # run: |
- # mkdir -p .cargo
- # curl -sL https://raw.githubusercontent.com/EmbarkStudios/rust-ecosystem/main/lints.toml >> .cargo/config.toml
-
- - name: Deny warnings
- shell: bash
- run: sed -i 's/rustflags = \[/rustflags = \[\n "-Dwarnings",/' .cargo/config.toml
-
- name: Run clippy
shell: bash
run: just clippy
@@ -291,10 +279,14 @@ jobs:
- name: Spell check
uses: crate-ci/typos@master
-
check-v2:
name: Check compilation for V2 features
runs-on: ubuntu-latest
+
+ env:
+ # Allow the `clippy::todo` lint for v2 checks
+ RUSTFLAGS: "-D warnings -A clippy::todo"
+
steps:
- name: Checkout repository
uses: actions/checkout@v4
@@ -326,13 +318,6 @@ jobs:
tool: just
checksum: true
- - name: Deny warnings
- shell: bash
- run: |
- sed -i 's/rustflags = \[/rustflags = \[\n "-Dwarnings",/' .cargo/config.toml
- # Allow the `clippy::todo` lint for v2 checks
- sed -i --null-data 's/ "-Wclippy::todo",\n//' .cargo/config.toml
-
- name: Cargo hack_v2
shell: bash
env:
diff --git a/.github/workflows/CI-push.yml b/.github/workflows/CI-push.yml
index a25667fc28..ace8d7eaf0 100644
--- a/.github/workflows/CI-push.yml
+++ b/.github/workflows/CI-push.yml
@@ -41,6 +41,9 @@ jobs:
name: Check compilation on MSRV toolchain
runs-on: ${{ matrix.runner }}
+ env:
+ RUSTFLAGS: "-D warnings"
+
strategy:
fail-fast: true
matrix:
@@ -87,10 +90,6 @@ jobs:
shell: bash
run: .github/scripts/install-jq.sh
- - name: Deny warnings
- shell: bash
- run: sed -i 's/rustflags = \[/rustflags = \[\n "-Dwarnings",/' .cargo/config.toml
-
- name: Cargo hack
if: ${{ github.event_name == 'push' }}
shell: bash
@@ -126,6 +125,9 @@ jobs:
name: Run tests on stable toolchain
runs-on: ${{ matrix.runner }}
+ env:
+ RUSTFLAGS: "-D warnings"
+
strategy:
fail-fast: true
matrix:
@@ -172,16 +174,6 @@ jobs:
with:
save-if: ${{ github.event_name == 'push' }}
- # - name: Setup Embark Studios lint rules
- # shell: bash
- # run: |
- # mkdir -p .cargo
- # curl -sL https://raw.githubusercontent.com/EmbarkStudios/rust-ecosystem/main/lints.toml >> .cargo/config.toml
-
- - name: Deny warnings
- shell: bash
- run: sed -i 's/rustflags = \[/rustflags = \[\n "-Dwarnings",/' .cargo/config.toml
-
- name: Run clippy
shell: bash
run: just clippy
diff --git a/Cargo.toml b/Cargo.toml
index fc2095275d..cb127dc6c4 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -2,12 +2,44 @@
resolver = "2"
members = ["crates/*"]
package.edition = "2021"
-package.rust-version = "1.70"
+package.rust-version = "1.76.0"
package.license = "Apache-2.0"
[workspace.dependencies]
tracing = { version = "0.1.40" }
+# Most of the lint configuration is based on https://github.com/EmbarkStudios/rust-ecosystem/blob/main/lints.toml
+[workspace.lints.rust]
+unsafe_code = "forbid"
+rust_2018_idioms = { level = "warn", priority = -1 } # Remove priority once https://github.com/rust-lang/rust-clippy/pull/12827 is available in stable clippy
+unused_qualifications = "warn"
+# missing_debug_implementations = "warn"
+# missing_docs = "warn"
+
+[workspace.lints.clippy]
+as_conversions = "warn"
+expect_used = "warn"
+index_refutable_slice = "warn"
+indexing_slicing = "warn"
+large_futures = "warn"
+match_on_vec_items = "warn"
+missing_panics_doc = "warn"
+out_of_bounds_indexing = "warn"
+panic = "warn"
+panic_in_result_fn = "warn"
+panicking_unwrap = "warn"
+print_stderr = "warn"
+print_stdout = "warn"
+todo = "warn"
+unimplemented = "warn"
+unreachable = "warn"
+unwrap_in_result = "warn"
+unwrap_used = "warn"
+use_self = "warn"
+
+# Lints to allow
+option_map_unit_fn = "allow"
+
[profile.release]
strip = true
lto = true
diff --git a/INSTALL_dependencies.sh b/INSTALL_dependencies.sh
index 871810ef32..4f2317e3f5 100755
--- a/INSTALL_dependencies.sh
+++ b/INSTALL_dependencies.sh
@@ -9,7 +9,7 @@ if [[ "${TRACE-0}" == "1" ]]; then
set -o xtrace
fi
-RUST_MSRV=1.70.0
+RUST_MSRV=1.76.0
_DB_NAME="hyperswitch_db"
_DB_USER="db_user"
_DB_PASS="db_password"
diff --git a/crates/analytics/Cargo.toml b/crates/analytics/Cargo.toml
index 70038e9827..24f2c6f96c 100644
--- a/crates/analytics/Cargo.toml
+++ b/crates/analytics/Cargo.toml
@@ -42,3 +42,6 @@ strum = { version = "0.26.2", features = ["derive"] }
thiserror = "1.0.58"
time = { version = "0.3.35", features = ["serde", "serde-well-known", "std"] }
tokio = { version = "1.37.0", features = ["macros", "rt-multi-thread"] }
+
+[lints]
+workspace = true
diff --git a/crates/analytics/src/main.rs b/crates/analytics/src/main.rs
deleted file mode 100644
index 5bf256ea97..0000000000
--- a/crates/analytics/src/main.rs
+++ /dev/null
@@ -1,3 +0,0 @@
-fn main() {
- println!("Hello world");
-}
diff --git a/crates/analytics/src/query.rs b/crates/analytics/src/query.rs
index cda40e2294..d9f85f9e77 100644
--- a/crates/analytics/src/query.rs
+++ b/crates/analytics/src/query.rs
@@ -744,7 +744,7 @@ where
query.push_str(format!(") _ WHERE top_n <= {}", top_n.count).as_str());
}
- println!("{}", query);
+ logger::debug!(%query);
Ok(query)
}
@@ -762,7 +762,7 @@ where
.build_query()
.change_context(QueryBuildingError::SqlSerializeError)
.attach_printable("Failed to execute query")?;
- logger::debug!(?query);
+
Ok(store.load_results(query.as_str()).await)
}
}
diff --git a/crates/api_models/Cargo.toml b/crates/api_models/Cargo.toml
index 10c4ee2692..9935e41faa 100644
--- a/crates/api_models/Cargo.toml
+++ b/crates/api_models/Cargo.toml
@@ -47,3 +47,6 @@ common_utils = { version = "0.1.0", path = "../common_utils" }
euclid = { version = "0.1.0", path = "../euclid" }
masking = { version = "0.1.0", path = "../masking", default-features = false, features = ["alloc", "serde"] }
router_derive = { version = "0.1.0", path = "../router_derive" }
+
+[lints]
+workspace = true
diff --git a/crates/api_models/src/lib.rs b/crates/api_models/src/lib.rs
index d6d6deaa23..938a6f2379 100644
--- a/crates/api_models/src/lib.rs
+++ b/crates/api_models/src/lib.rs
@@ -1,4 +1,3 @@
-#![forbid(unsafe_code)]
pub mod admin;
pub mod analytics;
pub mod api_keys;
diff --git a/crates/cards/Cargo.toml b/crates/cards/Cargo.toml
index 9091b1e697..1178568d72 100644
--- a/crates/cards/Cargo.toml
+++ b/crates/cards/Cargo.toml
@@ -24,3 +24,6 @@ router_env = { version = "0.1.0", path = "../router_env", features = ["log_extra
[dev-dependencies]
serde_json = "1.0.115"
+
+[lints]
+workspace = true
diff --git a/crates/common_enums/Cargo.toml b/crates/common_enums/Cargo.toml
index e29261192f..ba20438593 100644
--- a/crates/common_enums/Cargo.toml
+++ b/crates/common_enums/Cargo.toml
@@ -25,3 +25,6 @@ router_derive = { version = "0.1.0", path = "../router_derive" }
[dev-dependencies]
serde_json = "1.0.115"
+
+[lints]
+workspace = true
diff --git a/crates/common_utils/Cargo.toml b/crates/common_utils/Cargo.toml
index 40b9c10562..8507095119 100644
--- a/crates/common_utils/Cargo.toml
+++ b/crates/common_utils/Cargo.toml
@@ -65,3 +65,6 @@ signal-hook-tokio = { version = "0.3.1", features = ["futures-v0_3"], optional =
fake = "2.9.2"
proptest = "1.4.0"
test-case = "3.3.1"
+
+[lints]
+workspace = true
diff --git a/crates/common_utils/src/lib.rs b/crates/common_utils/src/lib.rs
index 197996629f..400da34998 100644
--- a/crates/common_utils/src/lib.rs
+++ b/crates/common_utils/src/lib.rs
@@ -1,4 +1,3 @@
-#![forbid(unsafe_code)]
#![warn(missing_docs, missing_debug_implementations)]
#![doc = include_str!(concat!(env!("CARGO_MANIFEST_DIR" ), "/", "README.md"))]
@@ -26,8 +25,6 @@ pub mod pii;
pub mod request;
#[cfg(feature = "signals")]
pub mod signals;
-#[allow(missing_docs)] // Todo: add docs
-pub mod static_cache;
pub mod transformers;
pub mod types;
pub mod validation;
diff --git a/crates/common_utils/src/static_cache.rs b/crates/common_utils/src/static_cache.rs
deleted file mode 100644
index 37705c892c..0000000000
--- a/crates/common_utils/src/static_cache.rs
+++ /dev/null
@@ -1,93 +0,0 @@
-use std::sync::{Arc, RwLock};
-
-use once_cell::sync::Lazy;
-use rustc_hash::FxHashMap;
-
-#[derive(Debug)]
-pub struct CacheEntry<T> {
- data: Arc<T>,
- timestamp: i64,
-}
-
-#[derive(Debug, Clone, thiserror::Error)]
-pub enum CacheError {
- #[error("Could not acquire the lock for cache entry")]
- CouldNotAcquireLock,
- #[error("Entry not found in cache")]
- EntryNotFound,
-}
-
-#[derive(Debug)]
-pub struct StaticCache<T> {
- data: Lazy<RwLock<FxHashMap<String, CacheEntry<T>>>>,
-}
-
-impl<T> StaticCache<T>
-where
- T: Send,
-{
- // Cannot have default impl as it cannot be called during instantiation of static item
- #[allow(clippy::new_without_default)]
- pub const fn new() -> Self {
- Self {
- data: Lazy::new(|| RwLock::new(FxHashMap::default())),
- }
- }
-
- pub fn present(&self, key: &String) -> Result<bool, CacheError> {
- let the_map = self
- .data
- .read()
- .map_err(|_| CacheError::CouldNotAcquireLock)?;
-
- Ok(the_map.get(key).is_some())
- }
-
- pub fn expired(&self, key: &String, timestamp: i64) -> Result<bool, CacheError> {
- let the_map = self
- .data
- .read()
- .map_err(|_| CacheError::CouldNotAcquireLock)?;
-
- Ok(match the_map.get(key) {
- None => false,
- Some(entry) => timestamp > entry.timestamp,
- })
- }
-
- pub fn retrieve(&self, key: &String) -> Result<Arc<T>, CacheError> {
- let the_map = self
- .data
- .read()
- .map_err(|_| CacheError::CouldNotAcquireLock)?;
-
- let cache_entry = the_map.get(key).ok_or(CacheError::EntryNotFound)?;
-
- Ok(Arc::clone(&cache_entry.data))
- }
-
- pub fn save(&self, key: String, data: T, timestamp: i64) -> Result<(), CacheError> {
- let mut the_map = self
- .data
- .write()
- .map_err(|_| CacheError::CouldNotAcquireLock)?;
-
- let entry = CacheEntry {
- data: Arc::new(data),
- timestamp,
- };
-
- the_map.insert(key, entry);
- Ok(())
- }
-
- pub fn clear(&self) -> Result<(), CacheError> {
- let mut the_map = self
- .data
- .write()
- .map_err(|_| CacheError::CouldNotAcquireLock)?;
-
- the_map.clear();
- Ok(())
- }
-}
diff --git a/crates/config_importer/Cargo.toml b/crates/config_importer/Cargo.toml
index 129abae15a..32721e9204 100644
--- a/crates/config_importer/Cargo.toml
+++ b/crates/config_importer/Cargo.toml
@@ -22,3 +22,6 @@ toml = { version = "0.8.12", default-features = false, features = ["parse"] }
[features]
default = ["preserve_order"]
preserve_order = ["dep:indexmap", "serde_json/preserve_order", "toml/preserve_order"]
+
+[lints]
+workspace = true
diff --git a/crates/connector_configs/Cargo.toml b/crates/connector_configs/Cargo.toml
index 4b0f810df2..1541a0864c 100644
--- a/crates/connector_configs/Cargo.toml
+++ b/crates/connector_configs/Cargo.toml
@@ -23,3 +23,6 @@ serde = { version = "1.0.197", features = ["derive"] }
serde_with = "3.7.0"
toml = "0.8.12"
utoipa = { version = "4.2.0", features = ["preserve_order", "preserve_path_order"] }
+
+[lints]
+workspace = true
diff --git a/crates/currency_conversion/Cargo.toml b/crates/currency_conversion/Cargo.toml
index bc255c57e1..d8309495b9 100644
--- a/crates/currency_conversion/Cargo.toml
+++ b/crates/currency_conversion/Cargo.toml
@@ -15,3 +15,6 @@ rust_decimal = "1.35"
rusty-money = { git = "https://github.com/varunsrin/rusty_money", rev = "bbc0150742a0fff905225ff11ee09388e9babdcc", features = ["iso", "crypto"] }
serde = { version = "1.0.197", features = ["derive"] }
thiserror = "1.0.58"
+
+[lints]
+workspace = true
diff --git a/crates/currency_conversion/src/conversion.rs b/crates/currency_conversion/src/conversion.rs
index 4cdca8fe0e..aa3122d803 100644
--- a/crates/currency_conversion/src/conversion.rs
+++ b/crates/currency_conversion/src/conversion.rs
@@ -28,7 +28,7 @@ pub fn convert(
#[cfg(test)]
mod tests {
- #![allow(clippy::expect_used)]
+ #![allow(clippy::expect_used, clippy::print_stdout)]
use std::collections::HashMap;
use crate::types::CurrencyFactors;
diff --git a/crates/diesel_models/Cargo.toml b/crates/diesel_models/Cargo.toml
index 6b63f76cda..45988f0f00 100644
--- a/crates/diesel_models/Cargo.toml
+++ b/crates/diesel_models/Cargo.toml
@@ -10,7 +10,7 @@ license.workspace = true
[features]
default = ["kv_store", "v1"]
kv_store = []
-v1 =[]
+v1 = []
v2 = []
business_profile_v2 = []
customer_v2 = []
@@ -36,3 +36,6 @@ common_utils = { version = "0.1.0", path = "../common_utils" }
masking = { version = "0.1.0", path = "../masking" }
router_derive = { version = "0.1.0", path = "../router_derive" }
router_env = { version = "0.1.0", path = "../router_env", features = ["log_extra_implicit_fields", "log_custom_entries_to_extra"] }
+
+[lints]
+workspace = true
diff --git a/crates/diesel_models/src/query/connector_response.rs b/crates/diesel_models/src/query/connector_response.rs
index db3ccd68cb..24d1f297cb 100644
--- a/crates/diesel_models/src/query/connector_response.rs
+++ b/crates/diesel_models/src/query/connector_response.rs
@@ -39,12 +39,11 @@ impl ConnectorResponseNew {
PaymentAttemptUpdateInternal::from(payment_attempt_update),
)
.await
- .map_err(|err| {
+ .inspect_err(|err| {
logger::error!(
"Error while updating payment attempt in connector_response flow {:?}",
err
);
- err
});
generics::generic_insert(conn, self).await
@@ -101,12 +100,11 @@ impl ConnectorResponse {
PaymentAttemptUpdateInternal::from(payment_attempt_update),
)
.await
- .map_err(|err| {
+ .inspect_err(|err| {
logger::error!(
"Error while updating payment attempt in connector_response flow {:?}",
err
);
- err
});
let connector_response_result =
diff --git a/crates/drainer/Cargo.toml b/crates/drainer/Cargo.toml
index d02917148e..9d626b8278 100644
--- a/crates/drainer/Cargo.toml
+++ b/crates/drainer/Cargo.toml
@@ -41,3 +41,6 @@ router_env = { version = "0.1.0", path = "../router_env", features = ["log_extra
[build-dependencies]
router_env = { version = "0.1.0", path = "../router_env", default-features = false }
+
+[lints]
+workspace = true
diff --git a/crates/drainer/src/handler.rs b/crates/drainer/src/handler.rs
index 8d6f7260fd..d8a8bff5af 100644
--- a/crates/drainer/src/handler.rs
+++ b/crates/drainer/src/handler.rs
@@ -193,10 +193,7 @@ async fn drainer_handler(
let output = store.make_stream_available(flag_stream_name.as_str()).await;
active_tasks.fetch_sub(1, atomic::Ordering::Release);
- output.map_err(|err| {
- logger::error!(operation = "unlock_stream", err=?err);
- err
- })
+ output.inspect_err(|err| logger::error!(operation = "unlock_stream", err=?err))
}
#[instrument(skip_all, fields(global_id, request_id, session_id))]
diff --git a/crates/drainer/src/main.rs b/crates/drainer/src/main.rs
index f3f822129c..c5a4a39f95 100644
--- a/crates/drainer/src/main.rs
+++ b/crates/drainer/src/main.rs
@@ -25,8 +25,11 @@ async fn main() -> DrainerResult<()> {
stores.insert(tenant_name.clone(), store);
}
+ #[allow(clippy::print_stdout)] // The logger has not yet been initialized
#[cfg(feature = "vergen")]
- println!("Starting drainer (Version: {})", router_env::git_tag!());
+ {
+ println!("Starting drainer (Version: {})", router_env::git_tag!());
+ }
let _guard = router_env::setup(
&conf.log,
diff --git a/crates/drainer/src/settings.rs b/crates/drainer/src/settings.rs
index 57c17f577b..0522673950 100644
--- a/crates/drainer/src/settings.rs
+++ b/crates/drainer/src/settings.rs
@@ -273,6 +273,8 @@ impl Settings<SecuredSecret> {
)
.build()?;
+ // The logger may not yet be initialized when constructing the application configuration
+ #[allow(clippy::print_stderr)]
serde_path_to_error::deserialize(config).map_err(|error| {
logger::error!(%error, "Unable to deserialize application configuration");
eprintln!("Unable to deserialize application configuration: {error}");
@@ -283,20 +285,28 @@ impl Settings<SecuredSecret> {
pub fn validate(&self) -> Result<(), errors::DrainerError> {
self.server.validate()?;
self.master_database.get_inner().validate()?;
+
+ // The logger may not yet be initialized when validating the application configuration
+ #[allow(clippy::print_stderr)]
self.redis.validate().map_err(|error| {
- println!("{error}");
+ eprintln!("{error}");
errors::DrainerError::ConfigParsingError("invalid Redis configuration".into())
})?;
self.drainer.validate()?;
+
+ // The logger may not yet be initialized when validating the application configuration
+ #[allow(clippy::print_stderr)]
self.secrets_management.validate().map_err(|error| {
- println!("{error}");
+ eprintln!("{error}");
errors::DrainerError::ConfigParsingError(
"invalid secrets management configuration".into(),
)
})?;
+ // The logger may not yet be initialized when validating the application configuration
+ #[allow(clippy::print_stderr)]
self.encryption_management.validate().map_err(|error| {
- println!("{error}");
+ eprintln!("{error}");
errors::DrainerError::ConfigParsingError(
"invalid encryption management configuration".into(),
)
diff --git a/crates/euclid/Cargo.toml b/crates/euclid/Cargo.toml
index c8cf00eb41..8f1320db23 100644
--- a/crates/euclid/Cargo.toml
+++ b/crates/euclid/Cargo.toml
@@ -36,3 +36,6 @@ criterion = "0.5"
name = "backends"
harness = false
required-features = ["ast_parser", "valued_jit"]
+
+[lints]
+workspace = true
diff --git a/crates/euclid_macros/Cargo.toml b/crates/euclid_macros/Cargo.toml
index d3bd99bfbe..b8e410a93b 100644
--- a/crates/euclid_macros/Cargo.toml
+++ b/crates/euclid_macros/Cargo.toml
@@ -15,3 +15,6 @@ quote = "1.0.35"
rustc-hash = "1.1.0"
strum = { version = "0.26", features = ["derive"] }
syn = "2.0.57"
+
+[lints]
+workspace = true
diff --git a/crates/euclid_wasm/Cargo.toml b/crates/euclid_wasm/Cargo.toml
index 47127c8212..55b2c8b84b 100644
--- a/crates/euclid_wasm/Cargo.toml
+++ b/crates/euclid_wasm/Cargo.toml
@@ -35,3 +35,6 @@ serde = { version = "1.0", features = [] }
serde-wasm-bindgen = "0.6.5"
strum = { version = "0.26", features = ["derive"] }
wasm-bindgen = { version = "0.2.92" }
+
+[lints]
+workspace = true
diff --git a/crates/events/Cargo.toml b/crates/events/Cargo.toml
index 335a3941d5..7af9a55339 100644
--- a/crates/events/Cargo.toml
+++ b/crates/events/Cargo.toml
@@ -17,3 +17,6 @@ serde = "1.0.197"
serde_json = "1.0.114"
thiserror = "1.0.58"
time = "0.3.34"
+
+[lints]
+workspace = true
diff --git a/crates/events/src/lib.rs b/crates/events/src/lib.rs
index cef0c8894d..3d333ec54b 100644
--- a/crates/events/src/lib.rs
+++ b/crates/events/src/lib.rs
@@ -1,6 +1,5 @@
#![cfg_attr(docsrs, feature(doc_auto_cfg, doc_cfg_hide))]
#![cfg_attr(docsrs, doc(cfg_hide(doc)))]
-#![forbid(unsafe_code)]
#![warn(missing_docs)]
//!
diff --git a/crates/external_services/Cargo.toml b/crates/external_services/Cargo.toml
index 5d91a477cd..2e33e0fafd 100644
--- a/crates/external_services/Cargo.toml
+++ b/crates/external_services/Cargo.toml
@@ -38,3 +38,6 @@ common_utils = { version = "0.1.0", path = "../common_utils" }
hyperswitch_interfaces = { version = "0.1.0", path = "../hyperswitch_interfaces", default-features = false }
masking = { version = "0.1.0", path = "../masking" }
router_env = { version = "0.1.0", path = "../router_env", features = ["log_extra_implicit_fields", "log_custom_entries_to_extra"] }
+
+[lints]
+workspace = true
diff --git a/crates/external_services/src/aws_kms/core.rs b/crates/external_services/src/aws_kms/core.rs
index f63c2000fe..8ffd631b81 100644
--- a/crates/external_services/src/aws_kms/core.rs
+++ b/crates/external_services/src/aws_kms/core.rs
@@ -59,12 +59,11 @@ impl AwsKmsClient {
.ciphertext_blob(ciphertext_blob)
.send()
.await
- .map_err(|error| {
+ .inspect_err(|error| {
// Logging using `Debug` representation of the error as the `Display`
// representation does not hold sufficient information.
logger::error!(aws_kms_sdk_error=?error, "Failed to AWS KMS decrypt data");
metrics::AWS_KMS_DECRYPTION_FAILURES.add(&metrics::CONTEXT, 1, &[]);
- error
})
.change_context(AwsKmsError::DecryptionFailed)?;
@@ -96,12 +95,11 @@ impl AwsKmsClient {
.plaintext(plaintext_blob)
.send()
.await
- .map_err(|error| {
+ .inspect_err(|error| {
// Logging using `Debug` representation of the error as the `Display`
// representation does not hold sufficient information.
logger::error!(aws_kms_sdk_error=?error, "Failed to AWS KMS encrypt data");
metrics::AWS_KMS_ENCRYPTION_FAILURES.add(&metrics::CONTEXT, 1, &[]);
- error
})
.change_context(AwsKmsError::EncryptionFailed)?;
@@ -169,7 +167,7 @@ impl AwsKmsConfig {
#[cfg(test)]
mod tests {
- #![allow(clippy::expect_used)]
+ #![allow(clippy::expect_used, clippy::print_stdout)]
#[tokio::test]
async fn check_aws_kms_encryption() {
std::env::set_var("AWS_SECRET_ACCESS_KEY", "YOUR SECRET ACCESS KEY");
diff --git a/crates/external_services/src/lib.rs b/crates/external_services/src/lib.rs
index 33ab754197..f4bcd91e34 100644
--- a/crates/external_services/src/lib.rs
+++ b/crates/external_services/src/lib.rs
@@ -1,6 +1,5 @@
//! Interactions with external systems.
-#![forbid(unsafe_code)]
#![warn(missing_docs, missing_debug_implementations)]
#[cfg(feature = "email")]
diff --git a/crates/hsdev/Cargo.toml b/crates/hsdev/Cargo.toml
index 3864996ece..df0d4c790c 100644
--- a/crates/hsdev/Cargo.toml
+++ b/crates/hsdev/Cargo.toml
@@ -14,3 +14,6 @@ diesel = { version = "2.1.6", features = ["postgres"] }
diesel_migrations = "2.1.0"
serde = { version = "1.0", features = ["derive"] }
toml = "0.5"
+
+[lints]
+workspace = true
diff --git a/crates/hsdev/src/main.rs b/crates/hsdev/src/main.rs
index e6ee9e17d4..d8c68fea42 100644
--- a/crates/hsdev/src/main.rs
+++ b/crates/hsdev/src/main.rs
@@ -1,3 +1,5 @@
+#![allow(clippy::print_stdout, clippy::print_stderr)]
+
use clap::{Parser, ValueHint};
use diesel::{pg::PgConnection, Connection};
use diesel_migrations::{FileBasedMigrations, HarnessWithOutput, MigrationHarness};
diff --git a/crates/hyperswitch_connectors/Cargo.toml b/crates/hyperswitch_connectors/Cargo.toml
index 2b199a3f72..5fb0bd0cc2 100644
--- a/crates/hyperswitch_connectors/Cargo.toml
+++ b/crates/hyperswitch_connectors/Cargo.toml
@@ -22,11 +22,14 @@ url = "2.5.0"
uuid = { version = "1.8.0", features = ["v4"] }
# First party crates
-api_models = { version = "0.1.0", path = "../api_models", features = ["errors"] , default-features = false}
+api_models = { version = "0.1.0", path = "../api_models", features = ["errors"], default-features = false }
cards = { version = "0.1.0", path = "../cards" }
common_enums = { version = "0.1.0", path = "../common_enums" }
common_utils = { version = "0.1.0", path = "../common_utils", features = ["signals", "async_ext", "logs", "metrics"] }
hyperswitch_domain_models = { version = "0.1.0", path = "../hyperswitch_domain_models", default-features = false }
-hyperswitch_interfaces = { version = "0.1.0", path = "../hyperswitch_interfaces" , default-features = false }
+hyperswitch_interfaces = { version = "0.1.0", path = "../hyperswitch_interfaces", default-features = false }
masking = { version = "0.1.0", path = "../masking" }
router_env = { version = "0.1.0", path = "../router_env", features = ["log_extra_implicit_fields", "log_custom_entries_to_extra"] }
+
+[lints]
+workspace = true
diff --git a/crates/hyperswitch_constraint_graph/Cargo.toml b/crates/hyperswitch_constraint_graph/Cargo.toml
index 34cf535d08..f7e596d4a6 100644
--- a/crates/hyperswitch_constraint_graph/Cargo.toml
+++ b/crates/hyperswitch_constraint_graph/Cargo.toml
@@ -15,3 +15,6 @@ rustc-hash = "1.1.0"
serde = { version = "1.0.163", features = ["derive", "rc"] }
strum = { version = "0.25", features = ["derive"] }
thiserror = "1.0.43"
+
+[lints]
+workspace = true
diff --git a/crates/hyperswitch_domain_models/Cargo.toml b/crates/hyperswitch_domain_models/Cargo.toml
index 16ab18b68d..4e00081961 100644
--- a/crates/hyperswitch_domain_models/Cargo.toml
+++ b/crates/hyperswitch_domain_models/Cargo.toml
@@ -47,3 +47,6 @@ thiserror = "1.0.58"
time = { version = "0.3.35", features = ["serde", "serde-well-known", "std"] }
url = { version = "2.5.0", features = ["serde"] }
utoipa = { version = "4.2.0", features = ["preserve_order", "preserve_path_order", "time"] }
+
+[lints]
+workspace = true
diff --git a/crates/hyperswitch_interfaces/Cargo.toml b/crates/hyperswitch_interfaces/Cargo.toml
index 887062d625..829db1f8d9 100644
--- a/crates/hyperswitch_interfaces/Cargo.toml
+++ b/crates/hyperswitch_interfaces/Cargo.toml
@@ -37,3 +37,6 @@ common_enums = { version = "0.1.0", path = "../common_enums" }
common_utils = { version = "0.1.0", path = "../common_utils" }
router_derive = { version = "0.1.0", path = "../router_derive" }
router_env = { version = "0.1.0", path = "../router_env" }
+
+[lints]
+workspace = true
diff --git a/crates/kgraph_utils/Cargo.toml b/crates/kgraph_utils/Cargo.toml
index 09c0ebd3e3..3e463441c2 100644
--- a/crates/kgraph_utils/Cargo.toml
+++ b/crates/kgraph_utils/Cargo.toml
@@ -33,3 +33,6 @@ criterion = "0.5"
[[bench]]
name = "evaluation"
harness = false
+
+[lints]
+workspace = true
diff --git a/crates/masking/Cargo.toml b/crates/masking/Cargo.toml
index c65fdaa96a..308d2dabbc 100644
--- a/crates/masking/Cargo.toml
+++ b/crates/masking/Cargo.toml
@@ -30,3 +30,6 @@ zeroize = { version = "1.7", default-features = false }
[dev-dependencies]
serde_json = "1.0.115"
+
+[lints]
+workspace = true
diff --git a/crates/masking/src/lib.rs b/crates/masking/src/lib.rs
index cb836e1884..5393438a87 100644
--- a/crates/masking/src/lib.rs
+++ b/crates/masking/src/lib.rs
@@ -1,6 +1,5 @@
#![cfg_attr(docsrs, feature(doc_auto_cfg, doc_cfg_hide))]
#![cfg_attr(docsrs, doc(cfg_hide(doc)))]
-#![forbid(unsafe_code)]
#![warn(missing_docs)]
//!
diff --git a/crates/openapi/Cargo.toml b/crates/openapi/Cargo.toml
index 98d80ffe9c..aff59027ee 100644
--- a/crates/openapi/Cargo.toml
+++ b/crates/openapi/Cargo.toml
@@ -18,4 +18,7 @@ router_env = { version = "0.1.0", path = "../router_env" }
[features]
default = ["v1"]
v2 = ["api_models/v2", "api_models/customer_v2", "api_models/merchant_account_v2", "api_models/routing_v2", "api_models/merchant_connector_account_v2"]
-v1 = ["api_models/v1"]
\ No newline at end of file
+v1 = ["api_models/v1"]
+
+[lints]
+workspace = true
diff --git a/crates/openapi/src/main.rs b/crates/openapi/src/main.rs
index 50782a81a7..f331edd681 100644
--- a/crates/openapi/src/main.rs
+++ b/crates/openapi/src/main.rs
@@ -4,6 +4,7 @@ mod openapi;
mod openapi_v2;
mod routes;
+#[allow(clippy::print_stdout)] // Using a logger is not necessary here
fn main() {
#[cfg(feature = "v1")]
let relative_file_path = "api-reference/openapi_spec.json";
diff --git a/crates/pm_auth/Cargo.toml b/crates/pm_auth/Cargo.toml
index a3c47e97d7..9766d7f19c 100644
--- a/crates/pm_auth/Cargo.toml
+++ b/crates/pm_auth/Cargo.toml
@@ -24,3 +24,6 @@ serde = "1.0.197"
serde_json = "1.0.115"
strum = { version = "0.26.2", features = ["derive"] }
thiserror = "1.0.58"
+
+[lints]
+workspace = true
diff --git a/crates/redis_interface/Cargo.toml b/crates/redis_interface/Cargo.toml
index e9dfc8cb51..f915956483 100644
--- a/crates/redis_interface/Cargo.toml
+++ b/crates/redis_interface/Cargo.toml
@@ -22,3 +22,6 @@ common_utils = { version = "0.1.0", path = "../common_utils", features = ["async
[dev-dependencies]
tokio = { version = "1.37.0", features = ["macros", "rt-multi-thread"] }
+
+[lints]
+workspace = true
diff --git a/crates/redis_interface/src/lib.rs b/crates/redis_interface/src/lib.rs
index fa35039800..3ef6b16bdb 100644
--- a/crates/redis_interface/src/lib.rs
+++ b/crates/redis_interface/src/lib.rs
@@ -14,7 +14,6 @@
//! // ... redis_conn ready to use
//! }
//! ```
-#![forbid(unsafe_code)]
pub mod commands;
pub mod errors;
diff --git a/crates/router/Cargo.toml b/crates/router/Cargo.toml
index e66028224d..00af58adfa 100644
--- a/crates/router/Cargo.toml
+++ b/crates/router/Cargo.toml
@@ -24,7 +24,7 @@ oltp = ["storage_impl/oltp"]
kv_store = ["scheduler/kv_store"]
accounts_cache = []
vergen = ["router_env/vergen"]
-dummy_connector = ["api_models/dummy_connector", "euclid/dummy_connector","hyperswitch_interfaces/dummy_connector", "kgraph_utils/dummy_connector"]
+dummy_connector = ["api_models/dummy_connector", "euclid/dummy_connector", "hyperswitch_interfaces/dummy_connector", "kgraph_utils/dummy_connector"]
external_access_dc = ["dummy_connector"]
detailed_errors = ["api_models/detailed_errors", "error-stack/serde"]
payouts = ["api_models/payouts", "common_enums/payouts", "hyperswitch_connectors/payouts", "hyperswitch_domain_models/payouts", "storage_impl/payouts"]
@@ -85,7 +85,7 @@ mime = "0.3.17"
nanoid = "0.4.0"
num_cpus = "1.16.0"
once_cell = "1.19.0"
-openidconnect = "3.5.0" # TODO: remove reqwest
+openidconnect = "3.5.0" # TODO: remove reqwest
openssl = "0.10.64"
qrcode = "0.14.0"
quick-xml = { version = "0.31.0", features = ["serialize"] }
@@ -132,11 +132,11 @@ cards = { version = "0.1.0", path = "../cards" }
common_enums = { version = "0.1.0", path = "../common_enums" }
common_utils = { version = "0.1.0", path = "../common_utils", features = ["signals", "async_ext", "logs", "metrics", "keymanager", "encryption_service"] }
currency_conversion = { version = "0.1.0", path = "../currency_conversion" }
-diesel_models = { version = "0.1.0", path = "../diesel_models", features = ["kv_store"] , default-features = false }
+diesel_models = { version = "0.1.0", path = "../diesel_models", features = ["kv_store"], default-features = false }
euclid = { version = "0.1.0", path = "../euclid", features = ["valued_jit"] }
events = { version = "0.1.0", path = "../events" }
external_services = { version = "0.1.0", path = "../external_services" }
-hyperswitch_connectors = { version = "0.1.0", path = "../hyperswitch_connectors" , default-features = false }
+hyperswitch_connectors = { version = "0.1.0", path = "../hyperswitch_connectors", default-features = false }
hyperswitch_constraint_graph = { version = "0.1.0", path = "../hyperswitch_constraint_graph" }
hyperswitch_domain_models = { version = "0.1.0", path = "../hyperswitch_domain_models", default-features = false }
hyperswitch_interfaces = { version = "0.1.0", path = "../hyperswitch_interfaces", default-features = false }
@@ -172,3 +172,6 @@ path = "src/bin/router.rs"
[[bin]]
name = "scheduler"
path = "src/bin/scheduler.rs"
+
+[lints]
+workspace = true
diff --git a/crates/router/src/bin/router.rs b/crates/router/src/bin/router.rs
index 0ec9411b99..5b6dd81501 100644
--- a/crates/router/src/bin/router.rs
+++ b/crates/router/src/bin/router.rs
@@ -18,8 +18,11 @@ async fn main() -> ApplicationResult<()> {
conf.validate()
.expect("Failed to validate router configuration");
+ #[allow(clippy::print_stdout)] // The logger has not yet been initialized
#[cfg(feature = "vergen")]
- println!("Starting router (Version: {})", router_env::git_tag!());
+ {
+ println!("Starting router (Version: {})", router_env::git_tag!());
+ }
let _guard = router_env::setup(
&conf.log,
diff --git a/crates/router/src/bin/scheduler.rs b/crates/router/src/bin/scheduler.rs
index 269c7d5b3b..e2da76d51d 100644
--- a/crates/router/src/bin/scheduler.rs
+++ b/crates/router/src/bin/scheduler.rs
@@ -1,4 +1,3 @@
-#![recursion_limit = "256"]
use std::{collections::HashMap, str::FromStr, sync::Arc};
use actix_web::{dev::Server, web, Scope};
@@ -67,11 +66,14 @@ async fn main() -> CustomResult<(), ProcessTrackerError> {
let scheduler_flow = scheduler::SchedulerFlow::from_str(&scheduler_flow_str)
.expect("Unable to parse SchedulerFlow from environment variable");
+ #[allow(clippy::print_stdout)] // The logger has not yet been initialized
#[cfg(feature = "vergen")]
- println!(
- "Starting {scheduler_flow} (Version: {})",
- router_env::git_tag!()
- );
+ {
+ println!(
+ "Starting {scheduler_flow} (Version: {})",
+ router_env::git_tag!()
+ );
+ }
let _guard = router_env::setup(
&state.conf.log,
@@ -99,7 +101,7 @@ async fn main() -> CustomResult<(), ProcessTrackerError> {
start_scheduler(&state, scheduler_flow, (tx, rx)).await?;
- eprintln!("Scheduler shut down");
+ logger::error!("Scheduler shut down");
Ok(())
}
diff --git a/crates/router/src/configs/settings.rs b/crates/router/src/configs/settings.rs
index f42f2218bd..312b7711f3 100644
--- a/crates/router/src/configs/settings.rs
+++ b/crates/router/src/configs/settings.rs
@@ -760,10 +760,14 @@ impl Settings<SecuredSecret> {
self.master_database.get_inner().validate()?;
#[cfg(feature = "olap")]
self.replica_database.get_inner().validate()?;
+
+ // The logger may not yet be initialized when validating the application configuration
+ #[allow(clippy::print_stderr)]
self.redis.validate().map_err(|error| {
- println!("{error}");
+ eprintln!("{error}");
ApplicationError::InvalidConfigurationValueError("Redis configuration".into())
})?;
+
if self.log.file.enabled {
if self.log.file.file_name.is_default_or_empty() {
return Err(error_stack::Report::from(
diff --git a/crates/router/src/connector/wellsfargo/transformers.rs b/crates/router/src/connector/wellsfargo/transformers.rs
index 44d0332dae..d368504a5f 100644
--- a/crates/router/src/connector/wellsfargo/transformers.rs
+++ b/crates/router/src/connector/wellsfargo/transformers.rs
@@ -814,7 +814,6 @@ fn build_bill_to(
email: pii::Email,
) -> Result<BillTo, error_stack::Report<errors::ConnectorError>> {
let phone_number = get_phone_number(address_details);
- println!(" ADESSS {:?}", address_details.clone());
let default_address = BillTo {
first_name: None,
last_name: None,
diff --git a/crates/router/src/core/payment_methods/cards.rs b/crates/router/src/core/payment_methods/cards.rs
index db731848db..6e9c97426e 100644
--- a/crates/router/src/core/payment_methods/cards.rs
+++ b/crates/router/src/core/payment_methods/cards.rs
@@ -1557,7 +1557,7 @@ pub async fn add_card_to_locker(
card_reference,
)
.await
- .map_err(|error| {
+ .inspect_err(|error| {
metrics::CARD_LOCKER_FAILURES.add(
&metrics::CONTEXT,
1,
@@ -1566,7 +1566,7 @@ pub async fn add_card_to_locker(
router_env::opentelemetry::KeyValue::new("operation", "add"),
],
);
- error
+ logger::error!(?error, "Failed to add card in locker");
})
},
&metrics::CARD_ADD_TIME,
@@ -1599,7 +1599,7 @@ pub async fn get_card_from_locker(
.await
.change_context(errors::ApiErrorResponse::InternalServerError)
.attach_printable("Failed while getting card from hyperswitch card vault")
- .map_err(|error| {
+ .inspect_err(|error| {
metrics::CARD_LOCKER_FAILURES.add(
&metrics::CONTEXT,
1,
@@ -1608,7 +1608,7 @@ pub async fn get_card_from_locker(
router_env::opentelemetry::KeyValue::new("operation", "get"),
],
);
- error
+ logger::error!(?error, "Failed to retrieve card from locker");
})
},
&metrics::CARD_GET_TIME,
@@ -1633,9 +1633,9 @@ pub async fn delete_card_from_locker(
async move {
delete_card_from_hs_locker(state, customer_id, merchant_id, card_reference)
.await
- .map_err(|error| {
+ .inspect_err(|error| {
metrics::CARD_LOCKER_FAILURES.add(&metrics::CONTEXT, 1, &[]);
- error
+ logger::error!(?error, "Failed to delete card from locker");
})
},
&metrics::CARD_DELETE_TIME,
diff --git a/crates/router/src/core/payment_methods/vault.rs b/crates/router/src/core/payment_methods/vault.rs
index 918522e7a9..54da4308bf 100644
--- a/crates/router/src/core/payment_methods/vault.rs
+++ b/crates/router/src/core/payment_methods/vault.rs
@@ -977,9 +977,9 @@ pub async fn create_tokenize(
)
.await
.map(|_| lookup_key.clone())
- .map_err(|err| {
+ .inspect_err(|error| {
metrics::TEMP_LOCKER_FAILURES.add(&metrics::CONTEXT, 1, &[]);
- err
+ logger::error!(?error, "Failed to store tokenized data in Redis");
})
.change_context(errors::ApiErrorResponse::InternalServerError)
.attach_printable("Error from redis locker")
diff --git a/crates/router/src/core/payments/helpers.rs b/crates/router/src/core/payments/helpers.rs
index 07ffcf443b..66f1e31ce3 100644
--- a/crates/router/src/core/payments/helpers.rs
+++ b/crates/router/src/core/payments/helpers.rs
@@ -4681,10 +4681,9 @@ pub async fn get_gsm_record(
};
get_gsm()
.await
- .map_err(|err| {
+ .inspect_err(|err| {
// warn log should suffice here because we are not propagating this error
logger::warn!(get_gsm_decision_fetch_error=?err, "error fetching gsm decision");
- err
})
.ok()
}
diff --git a/crates/router/src/core/payments/operations/payment_create.rs b/crates/router/src/core/payments/operations/payment_create.rs
index 97bc0a80c4..2b80598adf 100644
--- a/crates/router/src/core/payments/operations/payment_create.rs
+++ b/crates/router/src/core/payments/operations/payment_create.rs
@@ -1133,9 +1133,8 @@ impl PaymentCreate {
.charges
.as_ref()
.map(|charges| {
- charges.encode_to_value().map_err(|err| {
+ charges.encode_to_value().inspect_err(|err| {
logger::warn!("Failed to serialize PaymentCharges - {}", err);
- err
})
})
.transpose()
diff --git a/crates/router/src/core/payments/operations/payment_session.rs b/crates/router/src/core/payments/operations/payment_session.rs
index 8d6597efdd..371b028154 100644
--- a/crates/router/src/core/payments/operations/payment_session.rs
+++ b/crates/router/src/core/payments/operations/payment_session.rs
@@ -399,9 +399,8 @@ where
})
.filter_map(|parsed_payment_method_result| {
parsed_payment_method_result
- .map_err(|err| {
+ .inspect_err(|err| {
logger::error!(session_token_parsing_error=?err);
- err
})
.ok()
})
@@ -447,9 +446,8 @@ where
connector_type,
Some(merchant_connector_account.get_id()),
)
- .map_err(|err| {
+ .inspect_err(|err| {
logger::error!(session_token_error=?err);
- err
}) {
#[cfg(all(
any(feature = "v1", feature = "v2"),
diff --git a/crates/router/src/core/payouts/helpers.rs b/crates/router/src/core/payouts/helpers.rs
index 83afcefbb7..67e35e7dff 100644
--- a/crates/router/src/core/payouts/helpers.rs
+++ b/crates/router/src/core/payouts/helpers.rs
@@ -930,10 +930,9 @@ pub async fn get_gsm_record(
};
get_gsm()
.await
- .map_err(|err| {
+ .inspect_err(|err| {
// warn log should suffice here because we are not propagating this error
logger::warn!(get_gsm_decision_fetch_error=?err, "error fetching gsm decision");
- err
})
.ok()
}
diff --git a/crates/router/src/core/webhooks/outgoing.rs b/crates/router/src/core/webhooks/outgoing.rs
index 1a0e78a75a..36eadab612 100644
--- a/crates/router/src/core/webhooks/outgoing.rs
+++ b/crates/router/src/core/webhooks/outgoing.rs
@@ -161,12 +161,11 @@ pub(crate) async fn create_event_and_trigger_outgoing_webhook(
&event,
)
.await
- .map_err(|error| {
+ .inspect_err(|error| {
logger::error!(
?error,
"Failed to add outgoing webhook retry task to process tracker"
);
- error
})
.ok();
@@ -458,9 +457,8 @@ async fn raise_webhooks_analytics_event(
serde_json::to_value(error.current_context())
.change_context(errors::ApiErrorResponse::WebhookProcessingFailure)
- .map_err(|error| {
+ .inspect_err(|error| {
logger::error!(?error, "Failed to serialize outgoing webhook error as JSON");
- error
})
.ok()
} else {
diff --git a/crates/router/src/lib.rs b/crates/router/src/lib.rs
index 9f41983102..62e0b6fb31 100644
--- a/crates/router/src/lib.rs
+++ b/crates/router/src/lib.rs
@@ -1,6 +1,3 @@
-#![forbid(unsafe_code)]
-#![recursion_limit = "256"]
-
#[cfg(feature = "stripe")]
pub mod compatibility;
pub mod configs;
diff --git a/crates/router/src/middleware.rs b/crates/router/src/middleware.rs
index 1276db58dc..c80d14b9e2 100644
--- a/crates/router/src/middleware.rs
+++ b/crates/router/src/middleware.rs
@@ -284,9 +284,8 @@ where
content_length_header.to_str().map(ToOwned::to_owned)
})
.transpose()
- .map_err(|error| {
+ .inspect_err(|error| {
logger::warn!("Could not convert content length to string {error:?}");
- error
})
.ok()
.flatten();
diff --git a/crates/router/src/services/api.rs b/crates/router/src/services/api.rs
index b2571e6623..38d9b77703 100644
--- a/crates/router/src/services/api.rs
+++ b/crates/router/src/services/api.rs
@@ -183,7 +183,7 @@ where
Some(connector_request) => Some(connector_request),
None => connector_integration
.build_request(req, &state.conf.connectors)
- .map_err(|error| {
+ .inspect_err(|error| {
if matches!(
error.current_context(),
&errors::ConnectorError::RequestEncodingFailed
@@ -195,7 +195,6 @@ where
&add_attributes([("connector", req.connector.to_string())]),
)
}
- error
})?,
};
@@ -250,7 +249,7 @@ where
let connector_http_status_code = Some(body.status_code);
let handle_response_result = connector_integration
.handle_response(req, Some(&mut connector_event), body)
- .map_err(|error| {
+ .inspect_err(|error| {
if error.current_context()
== &errors::ConnectorError::ResponseDeserializationFailed
{
@@ -263,7 +262,6 @@ where
)]),
)
}
- error
});
match handle_response_result {
Ok(mut data) => {
diff --git a/crates/router/src/types/storage/payment_attempt.rs b/crates/router/src/types/storage/payment_attempt.rs
index 02182c25ec..669427d88c 100644
--- a/crates/router/src/types/storage/payment_attempt.rs
+++ b/crates/router/src/types/storage/payment_attempt.rs
@@ -87,7 +87,7 @@ impl AttemptStatusExt for enums::AttemptStatus {
#[cfg(test)]
#[cfg(feature = "dummy_connector")]
mod tests {
- #![allow(clippy::expect_used, clippy::unwrap_used)]
+ #![allow(clippy::expect_used, clippy::unwrap_used, clippy::print_stderr)]
use tokio::sync::oneshot;
use uuid::Uuid;
diff --git a/crates/router/src/workflows/outgoing_webhook_retry.rs b/crates/router/src/workflows/outgoing_webhook_retry.rs
index 40dfcfd005..19ef82c121 100644
--- a/crates/router/src/workflows/outgoing_webhook_retry.rs
+++ b/crates/router/src/workflows/outgoing_webhook_retry.rs
@@ -116,9 +116,8 @@ impl ProcessTrackerWorkflow<SessionState> for OutgoingWebhookRetryWorkflow {
let event = db
.insert_event(key_manager_state, new_event, &key_store)
.await
- .map_err(|error| {
+ .inspect_err(|error| {
logger::error!(?error, "Failed to insert event in events table");
- error
})?;
match &event.request {
diff --git a/crates/router/tests/cache.rs b/crates/router/tests/cache.rs
index f0c79e4dcb..8c3f34cd1e 100644
--- a/crates/router/tests/cache.rs
+++ b/crates/router/tests/cache.rs
@@ -1,4 +1,4 @@
-#![allow(clippy::unwrap_used)]
+#![allow(clippy::unwrap_used, clippy::print_stdout)]
use std::sync::Arc;
use router::{configs::settings::Settings, routes, services};
diff --git a/crates/router/tests/connectors/aci.rs b/crates/router/tests/connectors/aci.rs
index b1e6bbed29..1e829c8bdf 100644
--- a/crates/router/tests/connectors/aci.rs
+++ b/crates/router/tests/connectors/aci.rs
@@ -1,3 +1,5 @@
+#![allow(clippy::print_stdout)]
+
use std::{borrow::Cow, marker::PhantomData, str::FromStr, sync::Arc};
use api_models::payments::{Address, AddressDetails, PhoneDetails};
diff --git a/crates/router/tests/connectors/dlocal.rs b/crates/router/tests/connectors/dlocal.rs
index 4ef4b94503..62278d30ca 100644
--- a/crates/router/tests/connectors/dlocal.rs
+++ b/crates/router/tests/connectors/dlocal.rs
@@ -1,3 +1,5 @@
+#![allow(clippy::print_stdout)]
+
use std::str::FromStr;
use api_models::payments::Address;
diff --git a/crates/router/tests/customers.rs b/crates/router/tests/customers.rs
index 065f98fe66..47194c0f0e 100644
--- a/crates/router/tests/customers.rs
+++ b/crates/router/tests/customers.rs
@@ -1,4 +1,4 @@
-#![allow(clippy::unwrap_used)]
+#![allow(clippy::unwrap_used, clippy::print_stdout)]
mod utils;
diff --git a/crates/router/tests/payments.rs b/crates/router/tests/payments.rs
index 0f5dbf286a..8508e3d5cd 100644
--- a/crates/router/tests/payments.rs
+++ b/crates/router/tests/payments.rs
@@ -1,4 +1,9 @@
-#![allow(clippy::expect_used, clippy::unwrap_in_result, clippy::unwrap_used)]
+#![allow(
+ clippy::expect_used,
+ clippy::unwrap_in_result,
+ clippy::unwrap_used,
+ clippy::print_stdout
+)]
mod utils;
diff --git a/crates/router/tests/payments2.rs b/crates/router/tests/payments2.rs
index f5497b4293..f9a6e4a523 100644
--- a/crates/router/tests/payments2.rs
+++ b/crates/router/tests/payments2.rs
@@ -1,4 +1,9 @@
-#![allow(clippy::expect_used, clippy::unwrap_in_result, clippy::unwrap_used)]
+#![allow(
+ clippy::expect_used,
+ clippy::unwrap_in_result,
+ clippy::unwrap_used,
+ clippy::print_stdout
+)]
mod utils;
diff --git a/crates/router/tests/payouts.rs b/crates/router/tests/payouts.rs
index ab0bc891a7..b80623c6b3 100644
--- a/crates/router/tests/payouts.rs
+++ b/crates/router/tests/payouts.rs
@@ -1,4 +1,4 @@
-#![allow(clippy::unwrap_used)]
+#![allow(clippy::unwrap_used, clippy::print_stdout)]
mod utils;
diff --git a/crates/router/tests/refunds.rs b/crates/router/tests/refunds.rs
index 8d6a158cdf..dce0838df4 100644
--- a/crates/router/tests/refunds.rs
+++ b/crates/router/tests/refunds.rs
@@ -1,4 +1,4 @@
-#![allow(clippy::unwrap_used)]
+#![allow(clippy::unwrap_used, clippy::print_stdout)]
use utils::{mk_service, AppClient};
diff --git a/crates/router_derive/Cargo.toml b/crates/router_derive/Cargo.toml
index 82535e1bd1..1ab5ac2aca 100644
--- a/crates/router_derive/Cargo.toml
+++ b/crates/router_derive/Cargo.toml
@@ -26,3 +26,6 @@ serde_json = "1.0.115"
utoipa = "4.2.0"
common_utils = { version = "0.1.0", path = "../common_utils" }
+
+[lints]
+workspace = true
diff --git a/crates/router_derive/src/lib.rs b/crates/router_derive/src/lib.rs
index 31e28a2aaa..2931d9bdca 100644
--- a/crates/router_derive/src/lib.rs
+++ b/crates/router_derive/src/lib.rs
@@ -1,5 +1,4 @@
//! Utility macros for the `router` crate.
-#![forbid(unsafe_code)]
#![warn(missing_docs)]
use syn::parse_macro_input;
diff --git a/crates/router_env/Cargo.toml b/crates/router_env/Cargo.toml
index b9b1184fed..27fe451b75 100644
--- a/crates/router_env/Cargo.toml
+++ b/crates/router_env/Cargo.toml
@@ -44,3 +44,6 @@ log_custom_entries_to_extra = []
log_extra_implicit_fields = []
log_active_span_json = []
payouts = []
+
+[lints]
+workspace = true
diff --git a/crates/router_env/src/lib.rs b/crates/router_env/src/lib.rs
index 20518a9807..0d46f8ac33 100644
--- a/crates/router_env/src/lib.rs
+++ b/crates/router_env/src/lib.rs
@@ -1,4 +1,3 @@
-#![forbid(unsafe_code)]
#![warn(missing_debug_implementations)]
//!
diff --git a/crates/router_env/src/logger/config.rs b/crates/router_env/src/logger/config.rs
index 135451f266..03cc9ac17b 100644
--- a/crates/router_env/src/logger/config.rs
+++ b/crates/router_env/src/logger/config.rs
@@ -151,6 +151,8 @@ impl Config {
.add_source(config::Environment::with_prefix("ROUTER").separator("__"))
.build()?;
+ // The logger may not yet be initialized when constructing the application configuration
+ #[allow(clippy::print_stderr)]
serde_path_to_error::deserialize(config).map_err(|error| {
crate::error!(%error, "Unable to deserialize configuration");
eprintln!("Unable to deserialize application configuration: {error}");
diff --git a/crates/router_env/src/logger/setup.rs b/crates/router_env/src/logger/setup.rs
index 1a936fcebf..428112fb37 100644
--- a/crates/router_env/src/logger/setup.rs
+++ b/crates/router_env/src/logger/setup.rs
@@ -33,6 +33,7 @@ pub struct TelemetryGuard {
/// Setup logging sub-system specifying the logging configuration, service (binary) name, and a
/// list of external crates for which a more verbose logging must be enabled. All crates within the
/// current cargo workspace are automatically considered for verbose logging.
+#[allow(clippy::print_stdout)] // The logger hasn't been initialized yet
pub fn setup(
config: &config::Log,
service_name: &str,
@@ -271,6 +272,7 @@ fn setup_tracing_pipeline(
.install_batch(runtime::TokioCurrentThread)
.map(|tracer| tracing_opentelemetry::layer().with_tracer(tracer));
+ #[allow(clippy::print_stderr)] // The logger hasn't been initialized yet
if config.ignore_errors {
traces_layer_result
.map_err(|error| {
@@ -315,6 +317,7 @@ fn setup_metrics_pipeline(config: &config::LogTelemetry) -> Option<BasicControll
)]))
.build();
+ #[allow(clippy::print_stderr)] // The logger hasn't been initialized yet
if config.ignore_errors {
metrics_controller_result
.map_err(|error| eprintln!("Failed to setup metrics pipeline: {error:?}"))
diff --git a/crates/router_env/tests/env.rs b/crates/router_env/tests/env.rs
index 5251d2ab8e..e4609a4883 100644
--- a/crates/router_env/tests/env.rs
+++ b/crates/router_env/tests/env.rs
@@ -1,3 +1,5 @@
+#![allow(clippy::print_stdout)]
+
#[cfg(feature = "vergen")]
use router_env as env;
diff --git a/crates/scheduler/Cargo.toml b/crates/scheduler/Cargo.toml
index e962886908..df870d8fb9 100644
--- a/crates/scheduler/Cargo.toml
+++ b/crates/scheduler/Cargo.toml
@@ -36,3 +36,6 @@ hyperswitch_domain_models = { version = "0.1.0", path = "../hyperswitch_domain_m
redis_interface = { version = "0.1.0", path = "../redis_interface" }
router_env = { version = "0.1.0", path = "../router_env", features = ["log_extra_implicit_fields", "log_custom_entries_to_extra"] }
storage_impl = { version = "0.1.0", path = "../storage_impl", default-features = false }
+
+[lints]
+workspace = true
diff --git a/crates/scheduler/src/consumer.rs b/crates/scheduler/src/consumer.rs
index b58e8ce60d..5791edd31b 100644
--- a/crates/scheduler/src/consumer.rs
+++ b/crates/scheduler/src/consumer.rs
@@ -241,9 +241,8 @@ where
let res = workflow_selector
.trigger_workflow(&state.clone(), process.clone())
.await
- .map_err(|error| {
+ .inspect_err(|error| {
logger::error!(?error, "Failed to trigger workflow");
- error
});
metrics::TASK_PROCESSED.add(&metrics::CONTEXT, 1, &[]);
res
diff --git a/crates/storage_impl/Cargo.toml b/crates/storage_impl/Cargo.toml
index 2bfd90bf34..449fb008e7 100644
--- a/crates/storage_impl/Cargo.toml
+++ b/crates/storage_impl/Cargo.toml
@@ -15,7 +15,7 @@ payouts = ["hyperswitch_domain_models/payouts"]
v1 = ["api_models/v1", "diesel_models/v1", "hyperswitch_domain_models/v1"]
v2 = ["api_models/v2", "diesel_models/v2", "hyperswitch_domain_models/v2"]
payment_v2 = ["hyperswitch_domain_models/payment_v2", "diesel_models/payment_v2"]
-customer_v2 =["api_models/customer_v2", "diesel_models/customer_v2", "hyperswitch_domain_models/customer_v2"]
+customer_v2 = ["api_models/customer_v2", "diesel_models/customer_v2", "hyperswitch_domain_models/customer_v2"]
[dependencies]
# First Party dependencies
@@ -46,3 +46,6 @@ serde = { version = "1.0.197", features = ["derive"] }
serde_json = "1.0.115"
thiserror = "1.0.58"
tokio = { version = "1.37.0", features = ["rt-multi-thread"] }
+
+[lints]
+workspace = true
diff --git a/crates/storage_impl/src/lib.rs b/crates/storage_impl/src/lib.rs
index 6cac75c189..d4eadd4437 100644
--- a/crates/storage_impl/src/lib.rs
+++ b/crates/storage_impl/src/lib.rs
@@ -30,6 +30,7 @@ use database::store::PgPool;
use hyperswitch_domain_models::{PayoutAttemptInterface, PayoutsInterface};
pub use mock_db::MockDb;
use redis_interface::{errors::RedisError, RedisConnectionPool, SaddReply};
+use router_env::logger;
pub use crate::database::store::DatabaseStore;
#[cfg(not(feature = "payouts"))]
@@ -262,9 +263,9 @@ impl<T: DatabaseStore> KVRouterStore<T> {
)
.await
.map(|_| metrics::KV_PUSHED_TO_DRAINER.add(&metrics::CONTEXT, 1, &[]))
- .map_err(|err| {
+ .inspect_err(|error| {
metrics::KV_FAILED_TO_PUSH_TO_DRAINER.add(&metrics::CONTEXT, 1, &[]);
- err
+ logger::error!(?error, "Failed to add entry in drainer stream");
})
.change_context(RedisError::StreamAppendFailed)
}
diff --git a/crates/storage_impl/src/redis/kv_store.rs b/crates/storage_impl/src/redis/kv_store.rs
index b33deffda7..7e10584582 100644
--- a/crates/storage_impl/src/redis/kv_store.rs
+++ b/crates/storage_impl/src/redis/kv_store.rs
@@ -244,12 +244,11 @@ where
metrics::KV_OPERATION_SUCCESSFUL.add(&metrics::CONTEXT, 1, &[keyvalue]);
result
})
- .map_err(|err| {
+ .inspect_err(|err| {
logger::error!(kv_operation = %operation, status="error", error = ?err);
let keyvalue = router_env::opentelemetry::KeyValue::new("operation", operation);
metrics::KV_OPERATION_FAILED.add(&metrics::CONTEXT, 1, &[keyvalue]);
- err
})
}
diff --git a/crates/test_utils/Cargo.toml b/crates/test_utils/Cargo.toml
index 3b9eaa7329..8434c40989 100644
--- a/crates/test_utils/Cargo.toml
+++ b/crates/test_utils/Cargo.toml
@@ -31,3 +31,6 @@ toml = "0.8.12"
# First party crates
masking = { version = "0.1.0", path = "../masking" }
+
+[lints]
+workspace = true
diff --git a/crates/test_utils/src/lib.rs b/crates/test_utils/src/lib.rs
index f7cde3667d..bbacfab52e 100644
--- a/crates/test_utils/src/lib.rs
+++ b/crates/test_utils/src/lib.rs
@@ -1,2 +1,4 @@
+#![allow(clippy::print_stdout, clippy::print_stderr)]
+
pub mod connector_auth;
pub mod newman_runner;
diff --git a/crates/test_utils/src/main.rs b/crates/test_utils/src/main.rs
index 5b56b9a0d1..e163fe4d4b 100644
--- a/crates/test_utils/src/main.rs
+++ b/crates/test_utils/src/main.rs
@@ -1,3 +1,5 @@
+#![allow(clippy::print_stdout, clippy::print_stderr)]
+
use std::process::{exit, Command};
use anyhow::Result;
diff --git a/crates/test_utils/tests/connectors/main.rs b/crates/test_utils/tests/connectors/main.rs
index dca05cf92c..ab6b8cfe70 100644
--- a/crates/test_utils/tests/connectors/main.rs
+++ b/crates/test_utils/tests/connectors/main.rs
@@ -2,7 +2,8 @@
clippy::expect_used,
clippy::panic,
clippy::unwrap_in_result,
- clippy::unwrap_used
+ clippy::unwrap_used,
+ clippy::print_stderr
)]
mod aci_ui;
mod adyen_uk_ui;
diff --git a/scripts/add_connector.sh b/scripts/add_connector.sh
index 5fec357f15..c48809e66c 100755
--- a/scripts/add_connector.sh
+++ b/scripts/add_connector.sh
@@ -74,7 +74,7 @@ cd $conn/
# Generate template files for the connector
cargo install cargo-generate
-cargo gen-pg $payment_gateway
+cargo generate --path ../../../../connector-template -n $payment_gateway
# Move sub files and test files to appropriate folder
mv $payment_gateway/mod.rs $payment_gateway.rs