diff --git a/Cargo.lock b/Cargo.lock index 99a1266ba1..42e73554ab 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3124,7 +3124,6 @@ checksum = "27a72baa257b5e0e2de241967bc5ee8f855d6072351042688621081d66b2a76b" dependencies = [ "anyhow", "rustc_version 0.4.1", - "serde", ] [[package]] diff --git a/crates/analytics/src/query.rs b/crates/analytics/src/query.rs index 5b3059cab7..3e4f79254d 100644 --- a/crates/analytics/src/query.rs +++ b/crates/analytics/src/query.rs @@ -370,7 +370,7 @@ impl ToSql for FilterCombinator { #[derive(Debug, Clone)] pub enum Filter { Plain(String, FilterTypes, String), - NestedFilter(FilterCombinator, Vec), + NestedFilter(FilterCombinator, Vec), } impl Default for Filter { diff --git a/crates/api_models/Cargo.toml b/crates/api_models/Cargo.toml index 3582b8cb88..5c1c426309 100644 --- a/crates/api_models/Cargo.toml +++ b/crates/api_models/Cargo.toml @@ -10,7 +10,6 @@ license.workspace = true [features] errors = ["dep:actix-web", "dep:reqwest"] dummy_connector = ["euclid/dummy_connector", "common_enums/dummy_connector"] -detailed_errors = [] payouts = ["common_enums/payouts"] frm = [] olap = [] diff --git a/crates/api_models/src/errors/types.rs b/crates/api_models/src/errors/types.rs index 1a22a2d5cd..bb6065649a 100644 --- a/crates/api_models/src/errors/types.rs +++ b/crates/api_models/src/errors/types.rs @@ -16,8 +16,6 @@ pub struct ApiError { pub error_identifier: u16, pub error_message: String, pub extra: Option, - #[cfg(feature = "detailed_errors")] - pub stacktrace: Option, } impl ApiError { @@ -32,8 +30,6 @@ impl ApiError { error_identifier, error_message: error_message.to_string(), extra, - #[cfg(feature = "detailed_errors")] - stacktrace: None, } } } @@ -59,10 +55,6 @@ pub struct ErrorResponse { pub code: String, #[serde(flatten)] pub extra: Option, - - #[cfg(feature = "detailed_errors")] - #[serde(skip_serializing_if = "Option::is_none")] - pub stacktrace: Option, } impl From<&ApiErrorResponse> for ErrorResponse { @@ -74,9 +66,6 @@ impl From<&ApiErrorResponse> for ErrorResponse { message: error_info.error_message.clone(), error_type, extra: error_info.extra.clone(), - - #[cfg(feature = "detailed_errors")] - stacktrace: error_info.stacktrace.clone(), } } } diff --git a/crates/api_models/src/payment_methods.rs b/crates/api_models/src/payment_methods.rs index b78b6ebdce..886e91adcb 100644 --- a/crates/api_models/src/payment_methods.rs +++ b/crates/api_models/src/payment_methods.rs @@ -14,7 +14,7 @@ use common_utils::{ }; use masking::PeekInterface; use serde::de; -use utoipa::{schema, ToSchema}; +use utoipa::ToSchema; #[cfg(feature = "v1")] use crate::payments::BankCodeResponse; diff --git a/crates/common_utils/src/macros.rs b/crates/common_utils/src/macros.rs index 27836f236d..59c37daa61 100644 --- a/crates/common_utils/src/macros.rs +++ b/crates/common_utils/src/macros.rs @@ -730,8 +730,6 @@ macro_rules! impl_enum_str { mod tests { use serde_json::{json, Value as JsonValue}; - use crate::impl_enum_str; - impl_enum_str!( tag_delimiter = ":", #[derive(Debug, PartialEq, Clone)] diff --git a/crates/euclid/src/dssa/analyzer.rs b/crates/euclid/src/dssa/analyzer.rs index 74d7081ad1..20224b4dbe 100644 --- a/crates/euclid/src/dssa/analyzer.rs +++ b/crates/euclid/src/dssa/analyzer.rs @@ -246,11 +246,9 @@ mod tests { use hyperswitch_constraint_graph as cgraph; use super::*; - use crate::{ - dirval, - dssa::graph::{self, euclid_graph_prelude}, - types::DummyOutput, - }; + #[allow(unused_imports)] // Required by the `knowledge!` macro expansion + use crate::dssa::graph::euclid_graph_prelude; + use crate::{dirval, dssa::graph, types::DummyOutput}; #[test] fn test_conflicting_assertion_detection() { diff --git a/crates/euclid/src/dssa/truth.rs b/crates/euclid/src/dssa/truth.rs index 8724979888..885367559c 100644 --- a/crates/euclid/src/dssa/truth.rs +++ b/crates/euclid/src/dssa/truth.rs @@ -2,7 +2,9 @@ use std::sync::LazyLock; use euclid_macros::knowledge; -use crate::{dssa::graph::euclid_graph_prelude, frontend::dir}; +#[allow(unused_imports)] // Required by the `knowledge!` macro expansion +use crate::dssa::graph::euclid_graph_prelude; +use crate::frontend::dir; pub static ANALYSIS_GRAPH: LazyLock> = LazyLock::new(|| { diff --git a/crates/euclid/src/frontend/ast.rs b/crates/euclid/src/frontend/ast.rs index b887980675..d5935f3f96 100644 --- a/crates/euclid/src/frontend/ast.rs +++ b/crates/euclid/src/frontend/ast.rs @@ -120,7 +120,7 @@ pub type IfCondition = Vec; pub struct IfStatement { #[schema(value_type=Vec)] pub condition: IfCondition, - pub nested: Option>, + pub nested: Option>, } /// Represents a rule diff --git a/crates/euclid/src/frontend/dir.rs b/crates/euclid/src/frontend/dir.rs index c870df8e00..7adacc40ff 100644 --- a/crates/euclid/src/frontend/dir.rs +++ b/crates/euclid/src/frontend/dir.rs @@ -960,7 +960,7 @@ pub type DirIfCondition = Vec; #[derive(Debug, Clone)] pub struct DirIfStatement { pub condition: DirIfCondition, - pub nested: Option>, + pub nested: Option>, } #[derive(Debug, Clone)] diff --git a/crates/euclid/src/frontend/vir.rs b/crates/euclid/src/frontend/vir.rs index 6c8bc7ab2f..abccb7f4a7 100644 --- a/crates/euclid/src/frontend/vir.rs +++ b/crates/euclid/src/frontend/vir.rs @@ -21,7 +21,7 @@ pub type ValuedIfCondition = Vec; #[derive(Clone, Debug, Serialize, Deserialize)] pub struct ValuedIfStatement { pub condition: ValuedIfCondition, - pub nested: Option>, + pub nested: Option>, } #[derive(Clone, Debug, Serialize, Deserialize)] diff --git a/crates/hyperswitch_constraint_graph/src/error.rs b/crates/hyperswitch_constraint_graph/src/error.rs index cd2269de26..64ca3a2ac2 100644 --- a/crates/hyperswitch_constraint_graph/src/error.rs +++ b/crates/hyperswitch_constraint_graph/src/error.rs @@ -21,13 +21,13 @@ pub enum AnalysisTrace { }, AllAggregation { - unsatisfied: Vec>>, + unsatisfied: Vec>, info: Option<&'static str>, metadata: Option>, }, AnyAggregation { - unsatisfied: Vec>>, + unsatisfied: Vec>, info: Option<&'static str>, metadata: Option>, }, diff --git a/crates/hyperswitch_domain_models/src/payments.rs b/crates/hyperswitch_domain_models/src/payments.rs index bbf4aeab88..9d3bfdc338 100644 --- a/crates/hyperswitch_domain_models/src/payments.rs +++ b/crates/hyperswitch_domain_models/src/payments.rs @@ -1264,9 +1264,7 @@ where Some(connector) => Some(diesel_models::types::PaymentRevenueRecoveryMetadata { // Update retry count by one. total_retry_count: revenue_recovery.as_ref().map_or( - self.revenue_recovery_data - .retry_count - .map_or_else(|| 1, |retry_count| retry_count), + self.revenue_recovery_data.retry_count.unwrap_or(1), |data| (data.total_retry_count + 1), ), // Since this is an external system call, marking this payment_connector_transmission to ConnectorCallSucceeded. diff --git a/crates/router/Cargo.toml b/crates/router/Cargo.toml index fb01224513..7e82f906bd 100644 --- a/crates/router/Cargo.toml +++ b/crates/router/Cargo.toml @@ -28,7 +28,6 @@ accounts_cache = ["storage_impl/accounts_cache"] vergen = ["router_env/vergen"] dummy_connector = ["api_models/dummy_connector", "euclid/dummy_connector", "hyperswitch_interfaces/dummy_connector", "kgraph_utils/dummy_connector", "payment_methods/dummy_connector", "hyperswitch_domain_models/dummy_connector","hyperswitch_connectors/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", "payment_methods/payouts"] payout_retry = ["payouts"] recon = ["email", "api_models/recon"] diff --git a/crates/router/src/compatibility/stripe/errors.rs b/crates/router/src/compatibility/stripe/errors.rs index 6661fb9509..bbdc9fd75b 100644 --- a/crates/router/src/compatibility/stripe/errors.rs +++ b/crates/router/src/compatibility/stripe/errors.rs @@ -866,8 +866,6 @@ impl ErrorSwitch for errors::ApiErrorResponse { } } -impl crate::services::EmbedError for error_stack::Report {} - impl ErrorSwitch for CustomersErrorResponse { fn switch(&self) -> StripeErrorCode { use StripeErrorCode as SC; diff --git a/crates/router/src/compatibility/wrap.rs b/crates/router/src/compatibility/wrap.rs index d00ece8360..cfa7686711 100644 --- a/crates/router/src/compatibility/wrap.rs +++ b/crates/router/src/compatibility/wrap.rs @@ -32,7 +32,6 @@ where Q: Serialize + std::fmt::Debug + 'a + ApiEventMetric, S: TryFrom + Serialize, E: Serialize + error_stack::Context + actix_web::ResponseError + Clone, - error_stack::Report: services::EmbedError, errors::ApiErrorResponse: ErrorSwitch, T: std::fmt::Debug + Serialize + ApiEventMetric, { diff --git a/crates/router/src/core/errors.rs b/crates/router/src/core/errors.rs index a980bb664e..39b52e16ab 100644 --- a/crates/router/src/core/errors.rs +++ b/crates/router/src/core/errors.rs @@ -260,46 +260,6 @@ pub enum GooglePayDecryptionError { ParsingFailed, } -#[cfg(feature = "detailed_errors")] -pub mod error_stack_parsing { - - #[derive(serde::Deserialize)] - pub struct NestedErrorStack<'a> { - context: std::borrow::Cow<'a, str>, - attachments: Vec>, - sources: Vec>, - } - - #[derive(serde::Serialize, Debug)] - struct LinearErrorStack<'a> { - context: std::borrow::Cow<'a, str>, - #[serde(skip_serializing_if = "Vec::is_empty")] - attachments: Vec>, - } - - #[derive(serde::Serialize, Debug)] - pub struct VecLinearErrorStack<'a>(Vec>); - - impl<'a> From>> for VecLinearErrorStack<'a> { - fn from(value: Vec>) -> Self { - let multi_layered_errors: Vec<_> = value - .into_iter() - .flat_map(|current_error| { - [LinearErrorStack { - context: current_error.context, - attachments: current_error.attachments, - }] - .into_iter() - .chain(Into::>::into(current_error.sources).0) - }) - .collect(); - Self(multi_layered_errors) - } - } -} -#[cfg(feature = "detailed_errors")] -pub use error_stack_parsing::*; - #[derive(Debug, Clone, thiserror::Error)] pub enum RoutingError { #[error("Merchant routing algorithm not found in cache")] diff --git a/crates/router/src/core/payments/routing/utils.rs b/crates/router/src/core/payments/routing/utils.rs index c3b7dda97b..4b5ced7c01 100644 --- a/crates/router/src/core/payments/routing/utils.rs +++ b/crates/router/src/core/payments/routing/utils.rs @@ -1116,7 +1116,7 @@ pub type IfCondition = Vec; pub struct IfStatement { // #[schema(value_type=Vec)] pub condition: IfCondition, - pub nested: Option>, + pub nested: Option>, } /// Represents a rule diff --git a/crates/router/src/services/api.rs b/crates/router/src/services/api.rs index 8bcb83b4ab..ced9a4f023 100644 --- a/crates/router/src/services/api.rs +++ b/crates/router/src/services/api.rs @@ -568,50 +568,9 @@ where pub fn log_and_return_error_response(error: Report) -> HttpResponse where T: error_stack::Context + Clone + ResponseError, - Report: EmbedError, { logger::error!(?error); - HttpResponse::from_error(error.embed().current_context().clone()) -} - -pub trait EmbedError: Sized { - fn embed(self) -> Self { - self - } -} - -impl EmbedError for Report { - fn embed(self) -> Self { - #[cfg(feature = "detailed_errors")] - { - let mut report = self; - let error_trace = serde_json::to_value(&report).ok().and_then(|inner| { - serde_json::from_value::>>(inner) - .ok() - .map(Into::>::into) - .map(serde_json::to_value) - .transpose() - .ok() - .flatten() - }); - - match report.downcast_mut::() { - None => {} - Some(inner) => { - inner.get_internal_error_mut().stacktrace = error_trace; - } - } - report - } - - #[cfg(not(feature = "detailed_errors"))] - self - } -} - -impl EmbedError - for Report -{ + HttpResponse::from_error(error.current_context().clone()) } pub fn http_response_json(response: T) -> HttpResponse { diff --git a/crates/router_derive/src/macros/api_error.rs b/crates/router_derive/src/macros/api_error.rs index c3a8c1645a..b860de9add 100644 --- a/crates/router_derive/src/macros/api_error.rs +++ b/crates/router_derive/src/macros/api_error.rs @@ -152,6 +152,8 @@ fn implement_error_message( } quote! { + // Some fields of enum variants may not be used in the message + #[allow(unused_variables, unused_assignments)] pub fn error_message(&self) -> String { match self { #(#arms),* diff --git a/crates/scheduler/src/errors.rs b/crates/scheduler/src/errors.rs index 254c497952..ad79d7a54f 100644 --- a/crates/scheduler/src/errors.rs +++ b/crates/scheduler/src/errors.rs @@ -6,7 +6,7 @@ pub use redis_interface::errors::RedisError; pub use storage_impl::errors::ApplicationError; use storage_impl::errors::{RecoveryError, StorageError}; -use crate::env::logger::{self, error}; +use crate::env::logger; #[derive(Debug, thiserror::Error)] pub enum ProcessTrackerError { diff --git a/crates/storage_impl/src/payments/payment_attempt.rs b/crates/storage_impl/src/payments/payment_attempt.rs index 6a3d305f68..da926b5a48 100644 --- a/crates/storage_impl/src/payments/payment_attempt.rs +++ b/crates/storage_impl/src/payments/payment_attempt.rs @@ -430,8 +430,8 @@ impl PaymentAttemptInterface for RouterStore { use hyperswitch_domain_models::behaviour::Conversion; let conn = pg_connection_read(self).await?; - let intents = try_join_all(pi.iter().cloned().map(|pi| async { - Conversion::convert(pi) + let intents = try_join_all(pi.iter().map(|pi| async { + Conversion::convert(pi.clone()) .await .change_context(errors::StorageError::EncryptionError) })) diff --git a/crates/test_utils/src/newman_runner.rs b/crates/test_utils/src/newman_runner.rs index 096dec8254..d5d5df7be4 100644 --- a/crates/test_utils/src/newman_runner.rs +++ b/crates/test_utils/src/newman_runner.rs @@ -7,7 +7,7 @@ use std::{ }; use anyhow::{Context, Result}; -use clap::{arg, command, Parser, ValueEnum}; +use clap::{Parser, ValueEnum}; use masking::PeekInterface; use regex::Regex; diff --git a/crates/test_utils/tests/connectors/selenium.rs b/crates/test_utils/tests/connectors/selenium.rs index c7d0c20981..65df280813 100644 --- a/crates/test_utils/tests/connectors/selenium.rs +++ b/crates/test_utils/tests/connectors/selenium.rs @@ -16,8 +16,8 @@ use thirtyfour::{components::SelectElement, prelude::*, WebDriver}; #[derive(Clone)] pub enum Event<'a> { - RunIf(Assert<'a>, Vec>), - EitherOr(Assert<'a>, Vec>, Vec>), + RunIf(Assert<'a>, Vec), + EitherOr(Assert<'a>, Vec, Vec), Assert(Assert<'a>), Trigger(Trigger<'a>), }