fix(sync): skip pending auto-claim when multiple same-amount candidat…#2015
fix(sync): skip pending auto-claim when multiple same-amount candidat…#2015dale053 wants to merge 3 commits into
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
📝 WalkthroughWalkthroughfind_pending_transaction now materializes up to two pending candidates and only auto-claims when exactly one match exists; ambiguous same-amount candidate sets return nil. Tests assert multiple same-amount pendings are not stolen and single-pending claiming still works. ChangesPrevent silent same-amount pending claims
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Possibly related PRs
Suggested labels
Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 3 | ❌ 2❌ Failed checks (1 warning, 1 inconclusive)
✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
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 |
jjmata
left a comment
There was a problem hiding this comment.
Clean, minimal fix for a tricky edge case. A few observations:
The approach is correct. .limit(2).to_a followed by return nil if candidates.size != 1 is the right shape — it avoids fetching the full result set while still detecting ambiguity. No N+1 risk, no over-fetching.
Tests are thorough. All three scenarios (ambiguous collision → new entry, ATM scenario from the issue, single-candidate → still reconciles) are covered with clear assertions. The renamed test title ("does not auto-claim pending when multiple same-amount candidates exist") is much more descriptive than the old one.
Minor observation: The comment block inside find_pending_transaction is longer than typical for this codebase (per CLAUDE.md conventions — comments should be one short line explaining the non-obvious WHY). The return nil if candidates.size != 1 line is self-documenting enough; the multi-line explanation might be better suited to the PR description (where it already lives). Not a blocker.
Overall this is a solid, focused fix — no unnecessary changes, good regression coverage. 👍
Generated by Claude Code
Summary
.limit(2)guard infind_pending_transaction— if more than one same-amount candidate is found the method returnsnil, forcing a new posted entry to be created instead of blindly claiming an ambiguous pending.Test plan
bin/rails test test/models/account/provider_import_adapter_test.rb— all tests passbin/rubocop -f github -a— no offensesbin/brakeman --no-pager— no new warningsfixes #2013
Summary by CodeRabbit
Bug Fixes
Tests