You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
fix(api): await the batch update in deleteTransaction - #9602
api/transaction-delete read ['deleted'] from the Promise returned by transactions-batch-update instead of from its result. deleteTransaction therefore resolved with undefined before the delete had been applied, and an error from the delete never reached the caller. A read straight after await api.deleteTransaction() could still return the transaction and its transfer leg.
api/transaction-update had the same problem until #9307. This PR awaits the batch update in the delete handler too, and adds a test that covers both calls, with the toBeDefined() checks requested on #9097.
AI use: the fix and the test were written with Claude Code. I ran the test and the reproduction scripts on my own machine and checked the results.
Related issue(s)
Fixes#9104. The updateTransaction half of that issue was fixed in #9307; this is the deleteTransaction half. It picks up what was left of #9097, which the stale bot closed.
Testing
New test in packages/api/methods.test.ts: it sets a transfer payee on two transactions, deletes both, and checks that every call returns a value and that both accounts are empty straight after. It fails without the change and passes with it.
`api/transaction-delete` indexed the Promise returned by
`transactions-batch-update`, so `deleteTransaction` resolved with
`undefined` before the delete was applied, and an error from the delete
never reached the caller. `api/transaction-update` had the same problem
until actualbudget#9307.
Refs actualbudget#9104
We would love to review your PR! Before we can do that, please make sure:
✅ All CI checks pass
✅ The PR is moved from draft to open (if applicable)
✅ The "[WIP]" prefix is removed from the PR title
✅ The PR description follows the provided template, with all checklist boxes filled in
✅ All CodeRabbit code review comments are resolved (if you disagree with anything - reply to the bot with your reasoning so we can read through it). The bot will eventually approve the PR.
A quick note on volume: please get one PR reviewed and merged before opening several more. A stack of simultaneous, similar PRs from one author is reviewed slowly, and low-effort, untested, or undisclosed-AI PRs may be closed without a detailed review.
We do this to reduce the TOIL the core contributor team has to go through for each PR and to allow for speedy reviews and merges.
montjeffrey
changed the title
[AI] Await the batch update in API deleteTransaction
[AI] fix(api): await the batch update in deleteTransaction
Nov 19, 2026
montjeffrey
changed the title
[AI] fix(api): await the batch update in deleteTransaction
fix(api): await the batch update in deleteTransaction
Nov 19, 2026
CodeRabbit is using all valid settings from your configuration. Unrecognized properties (listed below) have been ignored and may indicate typos or deprecated fields that can be removed.
Parsing warnings: 1
Validation error: Unrecognized key: "enabled" at "reviews.pre_merge_checks.docstrings"
If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json
No actionable comments were generated in the recent review.
Walkthrough
The transaction-delete API now waits for the batch update before returning. Tests cover the returned result, error propagation, and transfer entries across two accounts. A release note describes the deletion behavior.
Changes: Transaction deletion
Layer / File(s)
Summary
Awaited deletion and regression coverage packages/loot-core/src/server/api.ts, packages/loot-core/src/server/api.test.ts, packages/api/methods.test.ts, upcoming-release-notes/fix-api-delete-transaction-await.md
The delete API awaits the batch-update handler. Tests check the returned transaction, database state, error propagation, and transfer entries after updates and deletions. The release note describes the deletion behavior.
deleteTransaction now resolves only after the deletion is applied, and batch-update errors reach the caller. No merge-blocking risk was found.
Pre-merge checks: 3 · 1
Failed checks: 1 inconclusive
Check name
Status
Explanation
Resolution
Linked Issues check
Issue #9104 has two coding requirements: updateTransaction and deleteTransaction must resolve only after the change, including the transfer leg, is applied. Delete requirement: the whole-PR diff of pa…
Confirm in packages/loot-core/src/server/api.ts at the merge base (or head) that api/transaction-update awaits transactions-batch-update before reading ['updated'], for example by a narrower read of that handler. If it does not, the update …
Passed checks: 3 passed
Check name
Status
Explanation
Title check
The title names the primary change: the delete handler now awaits the batch update in deleteTransaction. The raw summary confirms that api/transaction-delete now awaits transactions-batch-update befor…
Description check
The description explains the bug, the fix, the related issues (#9104, #9307, #9097), the added test in packages/api/methods.test.ts, and the testing done. It matches the changeset, which awaits the ba…
Out of Scope Changes check
The code change in api.ts is a one-line await fix within api/transaction-delete, which is the defect described in #9104. The test added to packages/api/methods.test.ts exercises the same delete and up…
Full details: Title check
Explanation
The title names the primary change: the delete handler now awaits the batch update in deleteTransaction. The raw summary confirms that api/transaction-delete now awaits transactions-batch-update before returning its deleted result, so the title matches the changeset.
Full details: Description check
Explanation
The description explains the bug, the fix, the related issues (#9104, #9307, #9097), the added test in packages/api/methods.test.ts, and the testing done. It matches the changeset, which awaits the batch update and adds tests.
Full details: Out of Scope Changes check
Explanation
The code change in api.ts is a one-line await fix within api/transaction-delete, which is the defect described in #9104. The test added to packages/api/methods.test.ts exercises the same delete and update flow and supports the requirement. The release note in upcoming-release-notes/ and the supporting test in packages/loot-core/src/server/api.test.ts (as listed in the change summary) document and verify the delete fix. No unrelated change was identified in the reviewed hunks.
Full details: Linked Issues check
Explanation
Issue #9104 has two coding requirements: updateTransaction and deleteTransaction must resolve only after the change, including the transfer leg, is applied. Delete requirement: the whole-PR diff of packages/loot-core/src/server/api.ts (merge base to head) changes api/transaction-delete from return handlers['transactions-batch-update'](diff)['deleted']; to return (await handlers['transactions-batch-update'](diff))['deleted'];. This addresses the reported defect for deleteTransaction. The new test in packages/api/methods.test.ts checks that both deletes return defined values and that both accounts are empty immediately afterward. Update requirement: the PR does not change api/transaction-update. The PR states that #9307 fixed this half. The merge-base read of api.ts was truncated before the transaction-update handler, so the presence of the await at the merge base could not be confirmed from source. Reference to #9307 alone is not evidence of presence. The update half therefore remains unverified.
Resolution
Confirm in packages/loot-core/src/server/api.ts at the merge base (or head) that api/transaction-update awaits transactions-batch-update before reading ['updated'], for example by a narrower read of that handler. If it does not, the update half of #9104 is unmet and requires the same await fix.
Finishing Touches
Generate unit tests (beta)
Create a new PR
Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
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.
Reviewing files that changed from the base of the PR and between 2d0af16 and 63fa6ca.
Files selected for processing: 1
packages/loot-core/src/server/api.test.ts
Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 9 remain after this review.
Call the handler directly so the test sits next to the fix: it checks
that the delete is applied and the deleted transaction returned before
the handler resolves, and that an error from the batch update rejects.
Both cases fail if the await in api/transaction-delete is removed.
Refs actualbudget#9104
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
api/transaction-deleteread['deleted']from the Promise returned bytransactions-batch-updateinstead of from its result.deleteTransactiontherefore resolved withundefinedbefore the delete had been applied, and an error from the delete never reached the caller. A read straight afterawait api.deleteTransaction()could still return the transaction and its transfer leg.api/transaction-updatehad the same problem until #9307. This PR awaits the batch update in the delete handler too, and adds a test that covers both calls, with thetoBeDefined()checks requested on #9097.AI use: the fix and the test were written with Claude Code. I ran the test and the reproduction scripts on my own machine and checked the results.
Related issue(s)
Fixes #9104. The
updateTransactionhalf of that issue was fixed in #9307; this is thedeleteTransactionhalf. It picks up what was left of #9097, which the stale bot closed.Testing
packages/api/methods.test.ts: it sets a transfer payee on two transactions, deletes both, and checks that every call returns a value and that both accounts are empty straight after. It fails without the change and passes with it.master, three runs per build (results in [Bug]: API updateTransaction/deleteTransaction resolve before the change is applied (transfer legs lost) #9104 (comment)): before the change, a read straight afterawait api.deleteTransaction()still returned one transaction and its transfer leg.calculatecase mentioned in [Bug]: API updateTransaction/deleteTransaction resolve before the change is applied (transfer legs lost) #9104.Checklist
Bundle Stats
View detailed bundle stats
desktop-client
Total
View detailed bundle breakdown
Added
No assets were added
Removed
No assets were removed
Bigger
Smaller
No assets were smaller
Unchanged
loot-core
Total
Changeset
home/runner/work/actual/actual/packages/loot-core/src/server/api.tsView detailed bundle breakdown
Added
Removed
Bigger
No assets were bigger
Smaller
No assets were smaller
Unchanged
No assets were unchanged
api
Total
Changeset
home/runner/work/actual/actual/packages/loot-core/src/server/api.tsView detailed bundle breakdown
Added
No assets were added
Removed
No assets were removed
Bigger
Smaller
No assets were smaller
Unchanged
cli
Total
View detailed bundle breakdown
Added
No assets were added
Removed
No assets were removed
Bigger
No assets were bigger
Smaller
No assets were smaller
Unchanged
crdt
Total
View detailed bundle breakdown
Added
No assets were added
Removed
No assets were removed
Bigger
No assets were bigger
Smaller
No assets were smaller
Unchanged