Repository navigation
fix(connectors): EN-1095 skip unsupported-currency rows + big.Int amount conversion (M-CON1, M-CON5) #781
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix(connectors): EN-1095 skip unsupported-currency rows + big.Int amount conversion (M-CON1, M-CON5) #781
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -3,15 +3,17 @@ package moneycorp | |
| import ( | ||
| "context" | ||
| "encoding/json" | ||
| "errors" | ||
| "fmt" | ||
| "strconv" | ||
| "time" | ||
|
|
||
| "github.com/formancehq/go-libs/v5/pkg/types/pointer" | ||
| "github.com/formancehq/go-libs/v5/pkg/types/currency" | ||
| "github.com/formancehq/go-libs/v5/pkg/types/pointer" | ||
| "github.com/formancehq/payments/internal/connectors/plugins/public/moneycorp/client" | ||
| "github.com/formancehq/payments/pkg/domain/models" | ||
| "github.com/formancehq/payments/pkg/domain/pagination" | ||
| "github.com/formancehq/payments/pkg/domain/plugins" | ||
| ) | ||
|
|
||
| type paymentsState struct { | ||
|
|
@@ -98,6 +100,12 @@ func (p *Plugin) toPSPPayments( | |
|
|
||
| payment, err := p.transactionToPayment(ctx, transaction) | ||
| if err != nil { | ||
| if errors.Is(err, plugins.ErrCurrencyNotSupported) { | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🟠 [major] Transfer path does not normalize unsupported-currency errors to plugins.ErrCurrencyNotSupported When a Moneycorp transaction is a debit Transfer, Suggestion: In the transfer path (e.g., |
||
| // Skip unsupported currencies rather than failing: a retryable | ||
| // error here would freeze ingestion for the whole account. | ||
| p.logger.WithField("transaction_id", transaction.ID).Info("skipping transaction with unsupported currency") | ||
| continue | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🟠 [major] Pagination watermark not advanced when all new rows are skipped due to unsupported currency When the only new Moneycorp transactions (or the newest tail) all have unsupported currencies, the Suggestion: Track the timestamp/ID of the last-seen row (supported or not) separately from the list of returned payments, and always advance the watermark to the latest processed row even when all are skipped due to unsupported currencies. |
||
| } | ||
|
coderabbitai[bot] marked this conversation as resolved.
Resolved
|
||
| return payments, err | ||
| } | ||
| if payment == nil { | ||
|
|
@@ -138,6 +146,9 @@ func (p *Plugin) transactionToPayment(ctx context.Context, transaction *client.T | |
|
|
||
| c, err := currency.GetPrecision(supportedCurrenciesWithDecimal, transaction.Attributes.Currency) | ||
| if err != nil { | ||
| if errors.Is(err, currency.ErrMissingCurrencies) { | ||
| return nil, fmt.Errorf("%w: %w", plugins.ErrCurrencyNotSupported, err) | ||
| } | ||
| return nil, err | ||
| } | ||
|
|
||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🟠 [major] Wrap unsupported currencies from Moneycorp transfer payments
When a Moneycorp transaction is a debit
Transfer,transactionToPaymentreturns throughfetchAndTranslateTransfer, whosetransferToPaymentstill returns the barecurrency.ErrMissingCurrenciesfor an unsupportedTransferCurrency. This new skip branch only catchesplugins.ErrCurrencyNotSupported, so those transfer rows still failFetchNextPaymentsand keep retrying instead of being skipped.