Skip to content

Fix 4 AccountService bugs found in bug hunt (each proven by a failing test) - #384

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

devin-ai-integration[bot] wants to merge 1 commit into
bug-hunt-demofrom
devin/1795061199-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 on bug-hunt-demo. Every bug below had a test that failed on bug-hunt-demo (11 failing → 11 passing). Fixes are the smallest change that makes each test pass.

# Bug Failing test(s) Fix
1 hasSufficientFunds is documented as "at least amount" but uses compareTo(amount) > 0. Withdrawing or transferring your entire balance is rejected with "Insufficient funds". hasSufficientFunds_isTrueWhenBalanceEqualsAmount, withdraw_entireBalance_succeeds, transfer_entireBalance_succeeds > 0 → >= 0
2 getTransactionHistory(account, from, to) is documented as "both days inclusive" but uses end = to.atStartOfDay() with isBefore(end), so it drops the whole to day (a single-day query returns nothing). transactionHistoryByDate_includesTransactionsOnTheToDay end = to.plusDays(1).atStartOfDay()
3 deposit / withdraw / transferAmount accept zero and negative amounts. A negative deposit lowers the balance, a negative withdrawal raises it, and a negative transfer pulls money out of the recipient's account. deposit_negativeAmount_isRejected, withdraw_negativeAmount_isRejected, transfer_negativeAmount_doesNotPullMoneyFromRecipient, transfer_zeroAmount_isRejected, BankControllerDepositTest.negativeDeposit_showsErrorOnDashboardAndLeavesBalanceUnchanged requirePositive(amount) guard at the start of each method; /deposit now catches the error and re-renders the dashboard with it (same pattern as /withdraw and /transfer) instead of returning a 500.
4 loadUserByUsername calls findAccountByUsername, which throws a plain RuntimeException for unknown users, so the UserDetailsService contract (UsernameNotFoundException) is broken and the null check was unreachable code. loadUserByUsername_unknownUser_throwsUsernameNotFoundException Look up via accountRepository.findByUsername(...).orElseThrow(UsernameNotFoundException::new)

Tests: src/test/.../service/AccountServiceBugHuntTest.java (Mockito unit tests) and src/test/.../controller/BankControllerDepositTest.java (MockMvc on the H2 test profile). Full suite: ./mvnw clean test → 11/11 pass.

Note: PRs #382 and #383 (earlier bug-hunt runs on the same base) cover the same bugs; only one should land.

Link to Devin session: https://devin-gtm.devinenterprise.com/sessions/01a2548792fa4eb1bb8f3a2abf1049c6
Open in Devin Desktop: https://devin-gtm.devinenterprise.com/desktop/session/01a2548792fa4eb1bb8f3a2abf1049c6?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

…nd unknown-user exception in AccountService

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

@devin-ai-integration

Copy link
Copy Markdown
Author

Browser-tested against local MySQL with two freshly registered accounts. Alice's exact $100 withdrawal and exact $50 transfer succeeded. The −$40 deposit, −$10 withdrawal, −$30 transfer, and $0 transfer each showed "Amount must be greater than zero," without changing either balance or adding transaction rows. Unknown username → /login?error (no 500). The service-only date-range fix is covered by unit tests, not the browser run.

Rejected −$40 deposit Alice's four valid transactions
Deposit rejected Transaction history
Exact withdrawal leaves $0 Bob's unchanged $50 balance
Exact withdrawal Bob unchanged

End-to-end recording

Written by Devin

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