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(ucs): Preserve invalid data errors in payment flows (#14955)

Pa1c66c90b1fe2d
diff --git a/crates/hyperswitch_interfaces/src/unified_connector_service/transformers.rs b/crates/hyperswitch_interfaces/src/unified_connector_service/transformers.rs
index 27ae77b99a..b9e648aeb4 100644
--- a/crates/hyperswitch_interfaces/src/unified_connector_service/transformers.rs
+++ b/crates/hyperswitch_interfaces/src/unified_connector_service/transformers.rs
@@ -2559,9 +2559,12 @@ impl ErrorSwitch<ConnectorError> for UnifiedConnectorServiceError {
// Connection/availability errors → ResponseHandlingFailed
Self::ConnectionError(_) => ConnectorError::ResponseHandlingFailed,
// Request encoding errors
- Self::RequestEncodingFailed
- | Self::RequestEncodingFailedWithReason(_)
- | Self::InvalidDataFormat { .. } => ConnectorError::RequestEncodingFailed,
+ Self::RequestEncodingFailed | Self::RequestEncodingFailedWithReason(_) => {
+ ConnectorError::RequestEncodingFailed
+ }
+ Self::InvalidDataFormat { field_name } => ConnectorError::InvalidDataFormat {
+ field_name: field_name.clone(),
+ },
// Missing field errors
Self::MissingRequiredField { field_name } => ConnectorError::MissingRequiredField {
field_name: field_name.clone(),
diff --git a/crates/router/src/core/errors/utils.rs b/crates/router/src/core/errors/utils.rs
index 4d93d685f0..42b4119ce6 100644
--- a/crates/router/src/core/errors/utils.rs
+++ b/crates/router/src/core/errors/utils.rs
@@ -396,6 +396,11 @@ impl<T> ConnectorErrorExt<T> for error_stack::Result<T, errors::ConnectorError>
field_name: field_name.clone(),
}
}
+ errors::ConnectorError::InvalidDataFormat { field_name } => {
+ errors::ApiErrorResponse::InvalidDataValue {
+ field_name: field_name.clone(),
+ }
+ }
errors::ConnectorError::FailedToObtainIntegrationUrl => {
errors::ApiErrorResponse::InvalidConnectorConfiguration {
config: "connector_account_details".to_string(),
@@ -453,7 +458,6 @@ impl<T> ConnectorErrorExt<T> for error_stack::Result<T, errors::ConnectorError>
| errors::ConnectorError::WebhookResponseEncodingFailed
| errors::ConnectorError::InvalidDateFormat
| errors::ConnectorError::DateFormattingFailed
- | errors::ConnectorError::InvalidDataFormat { .. }
| errors::ConnectorError::MismatchedPaymentData
| errors::ConnectorError::MandatePaymentDataMismatch { .. }
| errors::ConnectorError::MissingConnectorRelatedTransactionID { .. }