From 6c78e32d52ab1038eab2b8d82491c2292c8b5c66 Mon Sep 17 00:00:00 2001 From: Aleksey Kashapov Date: Tue, 1 Sep 2026 12:38:24 +0300 Subject: [PATCH 1/8] XYZ-451: Extends `limit_overflow` failure struct --- proto/payment_processing_errors.thrift | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/proto/payment_processing_errors.thrift b/proto/payment_processing_errors.thrift index f2f5479a..f8349445 100644 --- a/proto/payment_processing_errors.thrift +++ b/proto/payment_processing_errors.thrift @@ -1,3 +1,5 @@ +include "limiter_config.thrift" + namespace java dev.vality.damsel.payment_processing.errors namespace erlang dmsl.payproc_error @@ -154,16 +156,23 @@ union RoutesRejected { // использованию маршрута с такими лимитами 1: GeneralFailure limit_misconfiguration // Отвергнуты из-за превышения лимита - 2: GeneralFailure limit_overflow + 5: LimitOverflowFailure limit_overflow // Адаптер не доступен согласно полученной стате от FaultDetector'а 3: GeneralFailure adapter_unavailable // Согласно той же статистике конверсия провайдера упала ниже критического // порога и потому соответствующий маршрут/маршруты были отвергнуты 4: GeneralFailure provider_conversion_is_too_low + + // Deprecated, use LimitOverflowFailure instead + 2: GeneralFailure limit_overflow_legacy } union TermsViolated { 1: GeneralFailure insufficient_merchant_funds } +struct LimitOverflowFailure { + 1: string LimitConfigID limit_id +} + struct GeneralFailure {} From 269dc2efedae940c7d83fd40326ff0d978b464bd Mon Sep 17 00:00:00 2001 From: Aleksey Kashapov Date: Tue, 1 Sep 2026 12:55:38 +0300 Subject: [PATCH 2/8] Retires thrift compiler plugin --- rebar.config | 5 ----- 1 file changed, 5 deletions(-) diff --git a/rebar.config b/rebar.config index cca3e512..1f8010f3 100644 --- a/rebar.config +++ b/rebar.config @@ -45,11 +45,6 @@ {plt_apps, all_deps} ]}. -{plugins, [ - {rebar3_thrift_compiler, - {git, "https://github.com/valitydev/rebar3-thrift-compiler.git", {tag, "0.4"}}} -]}. - {provider_hooks, [ {pre, [ {compile, {thrift, compile}}, From fb8e1e9ce242239d8b905472a0f8ccbf44332d55 Mon Sep 17 00:00:00 2001 From: Aleksey Kashapov Date: Tue, 1 Sep 2026 12:57:26 +0300 Subject: [PATCH 3/8] Revert "Retires thrift compiler plugin" This reverts commit 269dc2efedae940c7d83fd40326ff0d978b464bd. --- rebar.config | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/rebar.config b/rebar.config index 1f8010f3..cca3e512 100644 --- a/rebar.config +++ b/rebar.config @@ -45,6 +45,11 @@ {plt_apps, all_deps} ]}. +{plugins, [ + {rebar3_thrift_compiler, + {git, "https://github.com/valitydev/rebar3-thrift-compiler.git", {tag, "0.4"}}} +]}. + {provider_hooks, [ {pre, [ {compile, {thrift, compile}}, From 2141b40c881a4dc975fa382a679bd6b733838098 Mon Sep 17 00:00:00 2001 From: Aleksey Kashapov Date: Tue, 1 Sep 2026 12:58:40 +0300 Subject: [PATCH 4/8] Fixes thrift typoes --- proto/payment_processing_errors.thrift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/proto/payment_processing_errors.thrift b/proto/payment_processing_errors.thrift index f8349445..1bc732a9 100644 --- a/proto/payment_processing_errors.thrift +++ b/proto/payment_processing_errors.thrift @@ -172,7 +172,7 @@ union TermsViolated { } struct LimitOverflowFailure { - 1: string LimitConfigID limit_id + 1: limiter_config.LimitConfigID limit_id } struct GeneralFailure {} From 5f006bde75946c2c69ccbff182031efa9a931cb7 Mon Sep 17 00:00:00 2001 From: Aleksey Kashapov Date: Tue, 1 Sep 2026 13:19:40 +0300 Subject: [PATCH 5/8] Fixes naming of property in now failure struct --- proto/payment_processing_errors.thrift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/proto/payment_processing_errors.thrift b/proto/payment_processing_errors.thrift index 1bc732a9..49ec1729 100644 --- a/proto/payment_processing_errors.thrift +++ b/proto/payment_processing_errors.thrift @@ -172,7 +172,7 @@ union TermsViolated { } struct LimitOverflowFailure { - 1: limiter_config.LimitConfigID limit_id + 1: limiter_config.LimitConfigID limit_config_id } struct GeneralFailure {} From 61e7a831b19b47284a1bd2fdd9cd12bfefb5e306 Mon Sep 17 00:00:00 2001 From: Aleksey Kashapov Date: Tue, 1 Sep 2026 13:32:23 +0300 Subject: [PATCH 6/8] Refactors into general failure w/ `reason_code` --- proto/payment_processing_errors.thrift | 13 +++---------- 1 file changed, 3 insertions(+), 10 deletions(-) diff --git a/proto/payment_processing_errors.thrift b/proto/payment_processing_errors.thrift index 49ec1729..48fdeea0 100644 --- a/proto/payment_processing_errors.thrift +++ b/proto/payment_processing_errors.thrift @@ -1,5 +1,3 @@ -include "limiter_config.thrift" - namespace java dev.vality.damsel.payment_processing.errors namespace erlang dmsl.payproc_error @@ -156,23 +154,18 @@ union RoutesRejected { // использованию маршрута с такими лимитами 1: GeneralFailure limit_misconfiguration // Отвергнуты из-за превышения лимита - 5: LimitOverflowFailure limit_overflow + 2: GeneralFailure limit_overflow // Адаптер не доступен согласно полученной стате от FaultDetector'а 3: GeneralFailure adapter_unavailable // Согласно той же статистике конверсия провайдера упала ниже критического // порога и потому соответствующий маршрут/маршруты были отвергнуты 4: GeneralFailure provider_conversion_is_too_low - - // Deprecated, use LimitOverflowFailure instead - 2: GeneralFailure limit_overflow_legacy } union TermsViolated { 1: GeneralFailure insufficient_merchant_funds } -struct LimitOverflowFailure { - 1: limiter_config.LimitConfigID limit_config_id +struct GeneralFailure { + 1: optional string reason_code } - -struct GeneralFailure {} From 06f8699aa9fa6238a3c0db7783dc90f42b824912 Mon Sep 17 00:00:00 2001 From: Aleksey Kashapov Date: Tue, 1 Sep 2026 15:16:16 +0300 Subject: [PATCH 7/8] Adds notes on `GeneralFailure.reason_code` --- proto/payment_processing_errors.thrift | 53 ++++++++++++++++++++++++++ 1 file changed, 53 insertions(+) diff --git a/proto/payment_processing_errors.thrift b/proto/payment_processing_errors.thrift index 48fdeea0..4fbd2d11 100644 --- a/proto/payment_processing_errors.thrift +++ b/proto/payment_processing_errors.thrift @@ -65,6 +65,59 @@ namespace erlang dmsl.payproc_error * } * ``` * + * ### Произвольный код ошибки общего назначения в разном представлении + * + * Статическая ошибка общего назначения GeneralFailure всегда выступает + * конечным типом и не имеет дочерних типов, но может быть использована для + * указания динамических кодов в конце цепочки статического представления + * ошибок. + * + * Для этого используется опциональное поле reason_code. + * При трансляции из статического в динамический формат, этот произвольный код + * будет представлени как SubFailure с соответствущим значением кода. + * + * Далее пример ошибки переполнения лимита при выборе маршрута процессинга + * платежа - конечным типом ошибки с кодом limit_overflow является + * GeneralFailure, а значит можно кодировать произвольный код в качестве его + * атрибута. + * + * ``` + * PaymentFailure{ + * no_route_found = NoRouteFoundFailure{ + * rejected = RoutesRejected{ + * limit_overflow = GeneralFailure{ + * reason_code = "over9000" + * } + * } + * } + * } + * ``` + * + * При обратной трансляции, из динамического в статическое представление, + * значение произвольного кода в конце набора кодов ошибки следует представлять + * в качестве значения reason_code у GeneralFailure только тогда когда в + * протоколе нет соответствующего статического кода со своим типом. + * + * ``` + * domain.Failure{ + * code = "no_route_found", + * reason = "blah blah who cares, i only want specific limit config id that failed", + * sub = domain.SubFailure{ + * code = "rejected", + * sub = domain.SubFailure{ + * code = "limit_overflow", + * sub = domain.SubFailure{ + * code = "over9000" + * } + * } + * } + * } + * ``` + * + * Что соответствует строковому представлению: + * + * no_route_found:rejected:limit_overflow:over9000 + * */ union PaymentFailure { From e434fa8fda147186e0ea192f6002cdbf92851b65 Mon Sep 17 00:00:00 2001 From: Aleksey Kashapov Date: Wed, 2 Sep 2026 10:52:15 +0300 Subject: [PATCH 8/8] Edits example of failure w/ `reason_code` --- proto/payment_processing_errors.thrift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/proto/payment_processing_errors.thrift b/proto/payment_processing_errors.thrift index 4fbd2d11..de3390d6 100644 --- a/proto/payment_processing_errors.thrift +++ b/proto/payment_processing_errors.thrift @@ -101,7 +101,7 @@ namespace erlang dmsl.payproc_error * ``` * domain.Failure{ * code = "no_route_found", - * reason = "blah blah who cares, i only want specific limit config id that failed", + * reason = "Limits overflow (over9000, 42, mylimit67)", * sub = domain.SubFailure{ * code = "rejected", * sub = domain.SubFailure{