Skip to content

Fix 4 AccountService bugs found by bug hunt (with failing tests) - #382

Open
devin-ai-integration[bot] wants to merge 1 commit into
bug-hunt-demofrom
devin/1795054752-bug-hunt-fixes
Open

devin-ai-integration[bot] wants to merge 1 commit into
bug-hunt-demofrom
devin/1795054752-bug-hunt-fixes

Conversation

@devin-ai-integration

@devin-ai-integration devin-ai-integration Bot commented Nov 19, 2026 •

Copy link
Copy Markdown

Summary

Bug-hunt results for AccountService. Each bug has a test that failed before this change and passes after it. Full suite: 11 tests, 0 failures (./mvnw clean test, H2 test profile).

# Bug Test(s) Fix
1 hasSufficientFunds used compareTo(amount) > 0, but its Javadoc says "at least", so users couldn't withdraw or transfer their entire balance hasSufficientFunds_isTrueWhenBalanceEqualsAmount, withdraw_entireBalanceSucceeds, transfer_entireBalanceSucceeds > 0 → >= 0
2 getTransactionHistory(account, from, to) documents "both days inclusive" but used end = to.atStartOfDay(), so the whole to day was dropped (a one-day range was always empty) transactionHistoryRange_includesTheToDay, transactionHistoryRange_includesLastMinuteOfToDay end = to.plusDays(1).atStartOfDay() (exclusive upper bound)
3 deposit / withdraw / transferAmount accepted negative amounts, e.g. transferAmount(alice, "bob", -500) moved 500 out of bob's account into alice's transfer_negativeAmountIsRejected, withdraw_negativeAmountIsRejected, deposit_negativeAmountIsRejected, BankControllerDepositTest.deposit_negativeAmountShowsErrorOnDashboard New requirePositive(amount) throws IllegalArgumentException("Amount must be greater than zero") for null, zero, or negative amounts. /deposit now catches it and renders the dashboard error, the same way /withdraw and /transfer already do (without this, a negative deposit returned a 500)
4 loadUserByUsername threw a plain RuntimeException for unknown users, which breaks the UserDetailsService contract; its account == null check could never run loadUserByUsername_unknownUserThrowsUsernameNotFoundException findAccountByUsername throws UsernameNotFoundException (a RuntimeException subclass, so existing controller catch blocks are unaffected); removed the dead null check

Dropped suspects (no failing test could be written): self-transfer (the balance nets to zero), and transferAmount not being @Transactional (no partial write could be triggered in a test).

Devin-Org: engineering

Link to Devin session: https://devin-gtm.devinenterprise.com/sessions/f15bb6af671c4ef094a7f6cce6692af6
Open in Devin Desktop: https://devin-gtm.devinenterprise.com/desktop/session/f15bb6af671c4ef094a7f6cce6692af6?variant=devin
Requested by: @gracejuan-star


Note

Devin errored when opening this Pull Request as gracejuan-star.
As a fallback, Devin opened this PR as itself.


Devin Review

…e amounts, UsernameNotFoundException

Co-Authored-By: Grace Juan <grace.juan@cognition.ai>
@devin-ai-integration

Copy link
Copy Markdown
Author

I'll fix CI failures and address comments from users with write access. I'll skip comments containing "(aside)".

  • Disable automatic comment, CI, and merge conflict monitoring

@devin-ai-integration devin-ai-integration Bot left a comment

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ Devin Review: No Issues Found

Devin Review analyzed this PR and found no bugs or issues to report.

Custom reviewers

  • ✨ Blast Radius Reviewer: no findings · View
  • 🛡️ API Security Reviewer: no findings · View

Devin Review

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

0 participants