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

fix: Invoke UCS in shadow mode even when the HS request fails HS↔UCS tunnel (#10544)

Amitsingh Tanwarc9dff2c089db
diff --git a/crates/router/src/core/payments/helpers.rs b/crates/router/src/core/payments/helpers.rs
index d522d942ec..f204f063ee 100644
--- a/crates/router/src/core/payments/helpers.rs
+++ b/crates/router/src/core/payments/helpers.rs
@@ -8659,10 +8659,15 @@ where
tokenization_action,
gateway_context,
)
- .await?;
+ .await;
+
+ // Spawn shadow UCS call in background regardless of HS result
+ // Use the initial router_data as fallback when HS fails
+ let direct_router_data = match &result {
+ Ok(success_data) => Some(success_data.0.clone()),
+ Err(_) => None,
+ };
- // Spawn shadow UCS call in background
- let direct_router_data = result.0.clone();
tokio::spawn(async move {
execute_shadow_unified_connector_service_call(
unified_connector_service_state,
@@ -8692,7 +8697,7 @@ where
.ok()
});
- Ok(result)
+ result
}
#[cfg(feature = "v1")]
@@ -8702,7 +8707,7 @@ where
pub async fn execute_shadow_unified_connector_service_call<F, RouterDReq>(
state: SessionState,
mut unified_connector_service_router_data: RouterData<F, RouterDReq, PaymentsResponseData>,
- direct_router_data: RouterData<F, RouterDReq, PaymentsResponseData>,
+ direct_router_data: Option<RouterData<F, RouterDReq, PaymentsResponseData>>,
header_payload: domain_payments::HeaderPayload,
lineage_ids: grpc_client::LineageIds,
merchant_connector_account: MerchantConnectorAccountType,
@@ -8739,7 +8744,7 @@ where
unified_connector_service_router_data.connector_customer = Some(id);
});
// Call UCS in shadow mode
- let _unified_connector_service_result = unified_connector_service_router_data
+ let unified_connector_service_result = unified_connector_service_router_data
.call_unified_connector_service(
&state,
&header_payload,
@@ -8752,23 +8757,42 @@ where
shadow_ucs_call_connector_action.unwrap_or(call_connector_action),
creds_identifier,
)
- .await
- .map_err(|e| router_env::logger::debug!("Shadow UCS call failed: {:?}", e));
+ .await;
- // Compare results
- match unified_connector_service::serialize_router_data_and_send_to_comparison_service(
- &state,
- direct_router_data,
- unified_connector_service_router_data,
- )
- .await
- {
- Ok(_) => {
- router_env::logger::debug!("Shadow UCS comparison completed successfully");
+ match (direct_router_data, unified_connector_service_result) {
+ (Some(direct_data), Ok(_)) => {
+ // Compare results
+ match unified_connector_service::serialize_router_data_and_send_to_comparison_service(
+ &state,
+ direct_data,
+ unified_connector_service_router_data,
+ )
+ .await
+ {
+ Ok(_) => {
+ router_env::logger::debug!("Shadow UCS comparison completed successfully");
+ Ok(())
+ }
+ Err(e) => {
+ router_env::logger::debug!("Shadow UCS comparison failed: {:?}", e);
+ Ok(())
+ }
+ }
+ }
+ (None, _) => {
+ router_env::logger::debug!(
+ "Direct call failed, skipping UCS router data comparison for payment_id={}",
+ unified_connector_service_payment_id
+ );
Ok(())
}
- Err(e) => {
- router_env::logger::debug!("Shadow UCS comparison failed: {:?}", e);
+ (_, Err(e)) => {
+ router_env::logger::debug!(
+ "
+ Skiping UCS router data comparison Shadow UCS call failed for payment_id={}: {:?}",
+ unified_connector_service_payment_id,
+ e
+ );
Ok(())
}
}