Repository navigation
fix(connectors): EN-1095 skip unsupported-currency rows + big.Int amount conversion (M-CON1, M-CON5) - #781
Conversation
…s (M-CON1) Unsupported-currency transactions/balances returned a retryable error from the fetch path. With no MaximumAttempts, FetchNext* retried the same row forever, freezing ingestion for the whole account while hammering the PSP. Adopt the wise/atlar pattern: translate wraps plugins.ErrCurrencyNotSupported and the fetch loop detects it via errors.Is, logs, and skips the row so ingestion continues for supported currencies. - stripe/payments.go: ErrUnsupportedCurrency now wraps the sentinel; loop skips - moneycorp/payments.go + balances.go: wrap currency.ErrMissingCurrencies, skip - plaid/client/amount_utils.go: wrap; plaid payments (Added/Modified) + balances skip - wise/balances.go: skip the single unsupported balance instead of erroring (audit missed this; wise/payments was already correct) Audit cited stripe/moneycorp/plaid; the cross-connector sweep also found wise/balances and confirmed moneycorp/transfers+payouts are create ops where failing on unsupported currency is correct (left unchanged). Constraint: Skipping (not just non-retryable) is required to keep ingesting other rows Rejected: Make the error non-retryable only | still drops the whole batch, ingestion stalls Confidence: high Scope-risk: moderate Directive: Currency skip applies to FETCH/ingestion loops only — outbound create ops must still fail on unsupported currency Not-tested: Real PSP behaviour when an account's own balance currency is unsupported
…64 (M-CON5) mapPayment computed the absolute amount as big.NewInt(int64(math.Abs(float64(transaction.Amount)))), round-tripping an int64 through float64. That loses precision above 2^53 minor units and overflows on MinInt64 (whose absolute value is not representable as int64). Use new(big.Int).Abs(big.NewInt(transaction.Amount)) — exact across the full int64 range and kept entirely in the integer domain. Drop the now-unused math import. Confidence: high Scope-risk: narrow Not-tested: amounts at exactly math.MinInt64 (test uses 2^53+1 to prove precision)
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (2)
WalkthroughThe PR updates Increase payment amount mapping to use integer absolute values and changes Moneycorp, Plaid, Stripe, and Wise connectors to skip balances or payments with unsupported currencies instead of failing. Tests were added or updated for each affected path. ChangesIncrease amount precision
Unsupported currency handling
Estimated code review effort🎯 4 (Complex) | ⏱️ ~60 minutes Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Warning There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure. 🔧 golangci-lint (2.12.2)level=error msg="[linters_context] typechecking error: pattern ./...: directory prefix . does not contain main module or its selected dependencies" Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
🛑 Changes requested — automated reviewThe PR successfully introduces skip logic for unsupported-currency rows across Moneycorp, Plaid, Stripe, and Wise connectors, and correctly switches Increase to integer absolute-value amount conversion. However, two major gaps remain in the Moneycorp implementation. First, the Transfer transaction code path returns the raw |
NumaryBot
left a comment
There was a problem hiding this comment.
NumaryBot posted 1 new inline finding.
Summary: #781 (comment)
|
|
||
| payment, err := p.transactionToPayment(ctx, transaction) | ||
| if err != nil { | ||
| if errors.Is(err, plugins.ErrCurrencyNotSupported) { |
There was a problem hiding this comment.
🟠 [major] Wrap unsupported currencies from Moneycorp transfer payments
When a Moneycorp transaction is a debit Transfer, transactionToPayment returns through fetchAndTranslateTransfer, whose transferToPayment still returns the bare currency.ErrMissingCurrencies for an unsupported TransferCurrency. This new skip branch only catches plugins.ErrCurrencyNotSupported, so those transfer rows still fail FetchNextPayments and keep retrying instead of being skipped.
There was a problem hiding this comment.
Actionable comments posted: 1
🧹 Nitpick comments (3)
internal/connectors/plugins/public/increase/payments_test.go (1)
640-673: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winAdd a
MinInt64regression case.These tests lock in the
2^53+1precision fix, but the other edge called out here isMinInt64, which is the boundary that breaks integer negation. Adding an explicitconst amount int64 = -1 << 63case would cover that exact failure mode too.🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@internal/connectors/plugins/public/increase/payments_test.go` around lines 640 - 673, Add an explicit MinInt64 regression test in the same mapPayment coverage alongside the existing large positive and negative amount cases. The current tests in mapPayment only verify the 2^53+1 precision fix; add a case using the exact MinInt64 boundary and assert the resulting payment amount is preserved correctly without overflow when taking the absolute value. Use the existing plg.mapPayment and payment.Amount assertions to cover this edge case.internal/connectors/plugins/public/stripe/payments_test.go (1)
233-242: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winAssert that the skip path still advances
NewState.This test covers the empty-page behavior, but it doesn't verify the part that prevents the retry loop: pagination state must still move forward after skipping the unsupported row. Returning a non-empty
client.Timelinehere and asserting it is serialized intores.NewStatewould lock in that contract.Suggested test tweak
m.EXPECT().GetPayments(gomock.Any(), accRef, gomock.Any(), int64(pageSize)).Return( p, - client.Timeline{}, + client.Timeline{LatestID: "someid"}, true, nil, ) res, err := plg.FetchNextPayments(ctx, req) Expect(err).To(BeNil()) Expect(res.Payments).To(BeEmpty()) Expect(res.HasMore).To(BeTrue()) + + var state paymentsState + err = json.Unmarshal(res.NewState, &state) + Expect(err).To(BeNil()) + Expect(state.Timeline.LatestID).To(Equal("someid"))🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@internal/connectors/plugins/public/stripe/payments_test.go` around lines 233 - 242, The empty-page test for FetchNextPayments only checks Payments and HasMore, but it does not verify that the pagination state advances after skipping the unsupported row. Update the test around plg.FetchNextPayments to return a non-empty client.Timeline from the mocked GetPayments call and assert that the resulting res.NewState contains the serialized timeline state, so the skip path in FetchNextPayments and its NewState handling are covered.internal/connectors/plugins/public/plaid/payments_test.go (1)
86-127: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winCover the ingestion-progress contract on the skipped-payment path.
This only proves the
Addedbranch is non-fatal. It doesn't verify that the cursor still advances (NewState/HasMore) after skipping, and it leaves the separateresp.Modifiedskip branch ininternal/connectors/plugins/public/plaid/payments.gounexercised. A regression in either path would still pass here. Based on PR objectives, the skipped-row path must keep ingestion moving.🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@internal/connectors/plugins/public/plaid/payments_test.go` around lines 86 - 127, The skipped-payment test in FetchNextPayments only asserts empty payments and misses the ingestion-progress contract. Update the plaid payments test around plg.FetchNextPayments to also verify cursor/state advancement (NewState and HasMore) after skipping unsupported currencies, using the same ListTransactions mock/NextCursor path. Add coverage for the resp.Modified skip branch in internal/connectors/plugins/public/plaid/payments.go so both skipped-row paths still advance ingestion correctly.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@internal/connectors/plugins/public/moneycorp/payments.go`:
- Around line 101-108: The transfer flow in `fetchAndTranslateTransfer` is
returning the raw missing-currency error instead of normalizing it, so
unsupported transfer transactions never match the skip path in
`transactionToPayment`. Update the transfer translation helper to wrap
`currency.ErrMissingCurrencies` as `plugins.ErrCurrencyNotSupported` (matching
the payment path), and make sure the `Transfer` branch still surfaces that
wrapped error through `transactionToPayment` so the existing skip logic in
`payments.go` can continue. Add a test in `payments_test.go` covering a `Type:
"Transfer"` transaction with an unsupported currency to verify it is skipped
rather than aborting ingestion.
---
Nitpick comments:
In `@internal/connectors/plugins/public/increase/payments_test.go`:
- Around line 640-673: Add an explicit MinInt64 regression test in the same
mapPayment coverage alongside the existing large positive and negative amount
cases. The current tests in mapPayment only verify the 2^53+1 precision fix; add
a case using the exact MinInt64 boundary and assert the resulting payment amount
is preserved correctly without overflow when taking the absolute value. Use the
existing plg.mapPayment and payment.Amount assertions to cover this edge case.
In `@internal/connectors/plugins/public/plaid/payments_test.go`:
- Around line 86-127: The skipped-payment test in FetchNextPayments only asserts
empty payments and misses the ingestion-progress contract. Update the plaid
payments test around plg.FetchNextPayments to also verify cursor/state
advancement (NewState and HasMore) after skipping unsupported currencies, using
the same ListTransactions mock/NextCursor path. Add coverage for the
resp.Modified skip branch in
internal/connectors/plugins/public/plaid/payments.go so both skipped-row paths
still advance ingestion correctly.
In `@internal/connectors/plugins/public/stripe/payments_test.go`:
- Around line 233-242: The empty-page test for FetchNextPayments only checks
Payments and HasMore, but it does not verify that the pagination state advances
after skipping the unsupported row. Update the test around plg.FetchNextPayments
to return a non-empty client.Timeline from the mocked GetPayments call and
assert that the resulting res.NewState contains the serialized timeline state,
so the skip path in FetchNextPayments and its NewState handling are covered.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: 3d6079f0-382c-4f93-8b14-bded520c6c97
📒 Files selected for processing (15)
internal/connectors/plugins/public/increase/payments.gointernal/connectors/plugins/public/increase/payments_test.gointernal/connectors/plugins/public/moneycorp/balances.gointernal/connectors/plugins/public/moneycorp/balances_test.gointernal/connectors/plugins/public/moneycorp/payments.gointernal/connectors/plugins/public/moneycorp/payments_test.gointernal/connectors/plugins/public/plaid/balances.gointernal/connectors/plugins/public/plaid/balances_test.gointernal/connectors/plugins/public/plaid/client/amount_utils.gointernal/connectors/plugins/public/plaid/payments.gointernal/connectors/plugins/public/plaid/payments_test.gointernal/connectors/plugins/public/stripe/payments.gointernal/connectors/plugins/public/stripe/payments_test.gointernal/connectors/plugins/public/wise/balances.gointernal/connectors/plugins/public/wise/balances_test.go
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #781 +/- ##
==========================================
+ Coverage 65.72% 65.74% +0.01%
==========================================
Files 859 859
Lines 39299 39324 +25
==========================================
+ Hits 25831 25854 +23
- Misses 11729 11735 +6
+ Partials 1739 1735 -4 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
…ch path (M-CON1) Addresses PR review: a debit Transfer routes toPSPPayments -> transactionToPayment -> fetchAndTranslateTransfer -> transferToPayment, which returned the bare currency.ErrMissingCurrencies for an unsupported TransferCurrency. The skip branch only catches plugins.ErrCurrencyNotSupported, so those transfer rows still failed FetchNextPayments and retried forever. Wrap the GetPrecision error in transferToPayment as plugins.ErrCurrencyNotSupported (matching the payment path) so the existing fetch-loop skip applies. Added a Type:"Transfer" unsupported-currency regression test. transferToPayment is also used by createTransfer, but that path validates the asset upfront, so wrapping is a no-op there. Confidence: high Scope-risk: narrow Directive: transferToPayment is on the FETCH path (via fetchAndTranslateTransfer), not only create — currency errors there must be skippable
NumaryBot
left a comment
There was a problem hiding this comment.
NumaryBot posted 2 new inline findings.
Summary: #781 (comment)
|
|
||
| payment, err := p.transactionToPayment(ctx, transaction) | ||
| if err != nil { | ||
| if errors.Is(err, plugins.ErrCurrencyNotSupported) { |
There was a problem hiding this comment.
🟠 [major] Transfer path does not normalize unsupported-currency errors to plugins.ErrCurrencyNotSupported
reported by NumaryBot, coderabbitai
When a Moneycorp transaction is a debit Transfer, transactionToPayment delegates to fetchAndTranslateTransfer, which calls currency.GetPrecision in transfers.go. Unlike the payment path, this helper returns the raw currency.ErrMissingCurrencies without wrapping it into plugins.ErrCurrencyNotSupported. The new skip branch at line 103–108 only catches plugins.ErrCurrencyNotSupported, so Transfer rows with unsupported currencies still cause FetchNextPayments to fail and retry instead of being silently skipped.
Suggestion: In the transfer path (e.g., transferToPayment or its call site), wrap currency.ErrMissingCurrencies into plugins.ErrCurrencyNotSupported (using errors.Is/fmt.Errorf with the appropriate sentinel), so the skip branch at the payments level catches all unsupported-currency cases uniformly regardless of transaction type.
| // 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 |
There was a problem hiding this comment.
🟠 [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 continue drops them from the returned payments slice. The caller advances LastCreatedAt based on payments[len(payments)-1], so the watermark remains unchanged. On the next poll, the same skipped rows are refetched and logged again, creating a permanent polling loop rather than truly skipping past those rows.
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.
Part 1 of 2 for EN-1095 (currency-error handling). Pagination/watermark fixes (M-CON2/M-CON3) follow in a separate PR.
M-CON1 — unsupported currency froze the fetch pipeline
Unsupported-currency rows returned a retryable error from the fetch path. With no
MaximumAttempts,FetchNext*retried the same row forever — ingestion frozen for the account while hammering the PSP.Fix: adopt the wise/atlar pattern — translate wraps
plugins.ErrCurrencyNotSupported, the fetch loop detects it viaerrors.Is, logs, and skips the row so other currencies keep flowing.stripe/payments.go,moneycorp/payments.go+balances.go,plaid(client/amount_utils.go+payments.go+balances.go)wise/balances.go— the audit missed this;wise/paymentswas already correct butbalancesbare-erroredmoneycorp/transfers.go+payouts.goare outbound create ops where failing on unsupported currency is correct; EE connectors are clean (cursor/since_id, not currency-gated)M-CON5 — increase converted money through float64
mapPaymentusedbig.NewInt(int64(math.Abs(float64(transaction.Amount)))), round-tripping anint64throughfloat64(loses precision above 2^53, overflows onMinInt64). Nownew(big.Int).Abs(big.NewInt(transaction.Amount))— exact across the full int64 range.Tests
TDD: existing "fails on unsupported currency" specs flipped to assert skip; new skip specs for balances; new precision spec for increase (2^53+1). All affected packages green;
go build ./...+go vetclean.