mirror of
https://github.com/juspay/hyperswitch.git
synced 2025-10-30 01:27:31 +08:00
fix: throw PreconditionFailed error when routing_algorithm is not configured (#1017)
Co-authored-by: Sanchith Hegde <22217505+SanchithHegde@users.noreply.github.com>
This commit is contained in:
@ -200,17 +200,17 @@ impl ByteSliceExt for [u8] {
|
|||||||
///
|
///
|
||||||
/// Extending functionalities of `serde_json::Value` for performing parsing
|
/// Extending functionalities of `serde_json::Value` for performing parsing
|
||||||
///
|
///
|
||||||
pub trait ValueExt<T> {
|
pub trait ValueExt {
|
||||||
///
|
///
|
||||||
/// Convert `serde_json::Value` into type `<T>` by using `serde::Deserialize`
|
/// Convert `serde_json::Value` into type `<T>` by using `serde::Deserialize`
|
||||||
///
|
///
|
||||||
fn parse_value(self, type_name: &str) -> CustomResult<T, errors::ParsingError>
|
fn parse_value<T>(self, type_name: &str) -> CustomResult<T, errors::ParsingError>
|
||||||
where
|
where
|
||||||
T: serde::de::DeserializeOwned;
|
T: serde::de::DeserializeOwned;
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<T> ValueExt<T> for serde_json::Value {
|
impl ValueExt for serde_json::Value {
|
||||||
fn parse_value(self, type_name: &str) -> CustomResult<T, errors::ParsingError>
|
fn parse_value<T>(self, type_name: &str) -> CustomResult<T, errors::ParsingError>
|
||||||
where
|
where
|
||||||
T: serde::de::DeserializeOwned,
|
T: serde::de::DeserializeOwned,
|
||||||
{
|
{
|
||||||
@ -225,11 +225,11 @@ impl<T> ValueExt<T> for serde_json::Value {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<T, MaskingStrategy> ValueExt<T> for Secret<serde_json::Value, MaskingStrategy>
|
impl<MaskingStrategy> ValueExt for Secret<serde_json::Value, MaskingStrategy>
|
||||||
where
|
where
|
||||||
MaskingStrategy: Strategy<serde_json::Value>,
|
MaskingStrategy: Strategy<serde_json::Value>,
|
||||||
{
|
{
|
||||||
fn parse_value(self, type_name: &str) -> CustomResult<T, errors::ParsingError>
|
fn parse_value<T>(self, type_name: &str) -> CustomResult<T, errors::ParsingError>
|
||||||
where
|
where
|
||||||
T: serde::de::DeserializeOwned,
|
T: serde::de::DeserializeOwned,
|
||||||
{
|
{
|
||||||
|
|||||||
@ -1203,11 +1203,15 @@ pub fn decide_connector(
|
|||||||
return Ok(api::ConnectorCallType::Single(connector_data));
|
return Ok(api::ConnectorCallType::Single(connector_data));
|
||||||
}
|
}
|
||||||
|
|
||||||
let routing_algorithm: api::RoutingAlgorithm = merchant_account
|
let routing_algorithm = merchant_account
|
||||||
.routing_algorithm
|
.routing_algorithm
|
||||||
.clone()
|
.clone()
|
||||||
.parse_value("RoutingAlgorithm")
|
.get_required_value("RoutingAlgorithm")
|
||||||
.change_context(errors::ApiErrorResponse::InternalServerError)
|
.change_context(errors::ApiErrorResponse::PreconditionFailed {
|
||||||
|
message: "no routing algorithm has been configured".to_string(),
|
||||||
|
})?
|
||||||
|
.parse_value::<api::RoutingAlgorithm>("RoutingAlgorithm")
|
||||||
|
.change_context(errors::ApiErrorResponse::InternalServerError) // Deserialization failed
|
||||||
.attach_printable("Unable to deserialize merchant routing algorithm")?;
|
.attach_printable("Unable to deserialize merchant routing algorithm")?;
|
||||||
|
|
||||||
let connector_name = match routing_algorithm {
|
let connector_name = match routing_algorithm {
|
||||||
|
|||||||
@ -20,7 +20,7 @@ pub trait OptionExt<T> {
|
|||||||
|
|
||||||
fn parse_value<U>(self, type_name: &'static str) -> CustomResult<U, errors::ParsingError>
|
fn parse_value<U>(self, type_name: &'static str) -> CustomResult<U, errors::ParsingError>
|
||||||
where
|
where
|
||||||
T: ValueExt<U>,
|
T: ValueExt,
|
||||||
U: serde::de::DeserializeOwned;
|
U: serde::de::DeserializeOwned;
|
||||||
|
|
||||||
fn update_value(&mut self, value: Option<T>);
|
fn update_value(&mut self, value: Option<T>);
|
||||||
@ -67,7 +67,7 @@ where
|
|||||||
|
|
||||||
fn parse_value<U>(self, type_name: &'static str) -> CustomResult<U, errors::ParsingError>
|
fn parse_value<U>(self, type_name: &'static str) -> CustomResult<U, errors::ParsingError>
|
||||||
where
|
where
|
||||||
T: ValueExt<U>,
|
T: ValueExt,
|
||||||
U: serde::de::DeserializeOwned,
|
U: serde::de::DeserializeOwned,
|
||||||
{
|
{
|
||||||
let value = self
|
let value = self
|
||||||
|
|||||||
Reference in New Issue
Block a user