Skip to content

fix(api): await the batch update in deleteTransaction - #9602

Merged
MatissJanis merged 3 commits into
actualbudget:masterfrom
montjeffrey:await-api-transaction-delete
Nov 22, 2026
Merged

MatissJanis merged 3 commits into
actualbudget:masterfrom
montjeffrey:await-api-transaction-delete

Conversation

@montjeffrey

@montjeffrey montjeffrey commented Nov 19, 2026 •

Copy link
Copy Markdown
Contributor

Description

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

Checklist

  • Release notes added (see link above)
  • No obvious regressions in affected areas
  • Self-review has been performed - I have read every line of this diff and can explain what each change does and why it is needed

Bundle Stats

Bundle Files count Total bundle size % Changed
desktop-client 37 15.11 MB → 15.11 MB (+492 B) +0.00%
loot-core 1 5.43 MB → 5.43 MB (+8 B) +0.00%
api 2 4.33 MB → 4.33 MB (+8 B) +0.00%
cli 1 420.19 kB 0%
crdt 1 11.15 kB 0%
View detailed bundle stats

desktop-client

Total

Files count Total bundle size % Changed
37 15.11 MB → 15.11 MB (+492 B) +0.00%
View detailed bundle breakdown

Added
No assets were added

Removed
No assets were removed

Bigger

Asset File Size % Changed
static/js/web.js 1 kB → 1.48 kB (+492 B) +47.86%

Smaller
No assets were smaller

Unchanged

Asset File Size % Changed
static/js/index.js 2.94 MB 0%
static/js/AutomaticSyncSettings.js 21.95 kB 0%
static/js/BackgroundImage.js 121.09 kB 0%
static/js/DateSelect.js 2.65 MB 0%
static/js/FormulaEditor.js 771.38 kB 0%
static/js/NotesTagFormatter.js 30.87 kB 0%
static/js/ReportRouter.js 2.01 MB 0%
static/js/TourHost.js 169.78 kB 0%
static/js/TransactionList.js 87.15 kB 0%
static/js/Value.js 1.76 MB 0%
static/js/bootstrapHyperFormula.js 302 B 0%
static/js/build-shims.js 140 B 0%
static/js/ca.js 161.65 kB 0%
static/js/columns.js 686.43 kB 0%
static/js/de.js 179.68 kB 0%
static/js/en-GB.js 13.59 kB 0%
static/js/en.js 292.41 kB 0%
static/js/es.js 181.74 kB 0%
static/js/fr.js 174.48 kB 0%
static/js/indexeddb-main-thread-worker-e59fee74.js 13.46 kB 0%
static/js/it.js 147.08 kB 0%
static/js/months.js 612.47 kB 0%
static/js/narrow.js 316.65 kB 0%
static/js/nb-NO.js 130.84 kB 0%
static/js/nl.js 142.79 kB 0%
static/js/pl.js 140.63 kB 0%
static/js/pt-BR.js 169.06 kB 0%
static/js/rolldown-runtime.js 2.03 kB 0%
static/js/ru.js 197.41 kB 0%
static/js/sv.js 308.36 kB 0%
static/js/theme.js 38.71 kB 0%
static/js/uk.js 237.6 kB 0%
static/js/useLocalPref.js 101.16 kB 0%
static/js/wide.js 304.34 kB 0%
static/js/workbox-window.prod.es5.js 7.21 kB 0%
static/js/zh-Hant.js 127.78 kB 0%

loot-core

Total

Files count Total bundle size % Changed
1 5.43 MB → 5.43 MB (+8 B) +0.00%
Changeset
File Δ Size
home/runner/work/actual/actual/packages/loot-core/src/server/api.ts 📈 +8 B (+0.03%) 28.85 kB → 28.86 kB
View detailed bundle breakdown

Added

Asset File Size % Changed
kcab.worker.CJg2UeDE.js 0 B → 5.43 MB (+5.43 MB) -

Removed

Asset File Size % Changed
kcab.worker.CKIlxGuB.js 5.43 MB → 0 B (-5.43 MB) -100%

Bigger
No assets were bigger

Smaller
No assets were smaller

Unchanged
No assets were unchanged


api

Total

Files count Total bundle size % Changed
2 4.33 MB → 4.33 MB (+8 B) +0.00%
Changeset
File Δ Size
home/runner/work/actual/actual/packages/loot-core/src/server/api.ts 📈 +8 B (+0.03%) 28.12 kB → 28.13 kB
View detailed bundle breakdown

Added
No assets were added

Removed
No assets were removed

Bigger

Asset File Size % Changed
index.js 4.33 MB → 4.33 MB (+8 B) +0.00%

Smaller
No assets were smaller

Unchanged

Asset File Size % Changed
models.js 0 B 0%

cli

Total

Files count Total bundle size % Changed
1 420.19 kB 0%
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

Asset File Size % Changed
cli.js 420.19 kB 0%

crdt

Total

Files count Total bundle size % Changed
1 11.15 kB 0%
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

Asset File Size % Changed
index.js 11.15 kB 0%

`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
@netlify

netlify Bot commented Nov 19, 2026 •

Copy link
Copy Markdown

✅ Deploy Preview for actualbudget ready!

Built without sensitive environment variables

Name Link
🔨 Latest commit 63fa6ca
🔍 Latest deploy log https://app.netlify.com/projects/actualbudget/deploys/6b0213fb4a3808ba84a3e0af
😎 Deploy Preview https://deploy-preview-9602.demo.actualbudget.org
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.
🤖 Make changes Run an agent on this branch

To edit notification comments on pull requests, go to your Netlify project configuration.

@github-actions

Copy link
Copy Markdown
Contributor

👋 Hello contributor!

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.
  • ✅ Any AI usage is disclosed (see our AI Usage Policy)

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.

For more information, please see our Contributing Guide.

@montjeffrey 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 montjeffrey changed the title [AI] fix(api): await the batch update in deleteTransaction fix(api): await the batch update in deleteTransaction Nov 19, 2026
@montjeffrey
montjeffrey marked this pull request as ready for review November 19, 2026 21:05
@coderabbitai coderabbitai Bot added API Issues with the @actual-app/api package size small possible low quality labels Nov 19, 2026
@coderabbitai

coderabbitai Bot commented Nov 19, 2026 •

Copy link
Copy Markdown
Contributor

Explain Change →

Note

.coderabbit.yaml has unrecognized properties

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"
Configuration instructions

  • Please see the configuration documentation for more information.
  • You can also validate your configuration using the online YAML validator.
  • 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.

Estimated code review effort: 2 (Simple) | ~10 minutes

Change: Bug fix · Severity of issue fixed: Medium

Suggested labels: API

Suggested reviewers: matt-fidd

Merge Risk: Minimal · up to 63fa6

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: Passed 3 · Inconclusive 1

Failed Failed checks: 1 inconclusive

Check name Status Explanation Resolution
Linked Issues check Inconclusive 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 Passed checks: 3 passed

Check name Status Explanation
Title check Passed 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 Passed 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 Passed 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.

Share

Recent review info

Run configuration

Commits

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.

coderabbitai[bot]
coderabbitai Bot previously approved these changes Nov 19, 2026
Comment thread packages/api/methods.test.ts Resolved
@netlify

netlify Bot commented Nov 20, 2026 •

Copy link
Copy Markdown

✅ Deploy Preview for actualbudget-website ready!

Built without sensitive environment variables

Name Link
🔨 Latest commit 63fa6ca
🔍 Latest deploy log https://app.netlify.com/projects/actualbudget-website/deploys/6b0213fb84eba994f4237b4f
😎 Deploy Preview https://deploy-preview-9602.www.actualbudget.org
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.
🤖 Make changes Run an agent on this branch

To edit notification comments on pull requests, go to your Netlify project configuration.

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
@montjeffrey
montjeffrey force-pushed the await-api-transaction-delete branch from 4fb5ba8 to e017cd2 Compare November 20, 2026 19:40
@github-actions

Copy link
Copy Markdown
Contributor

VRT tests ❌ failed. View the test report.

To update the VRT screenshots, comment /update-vrt on this PR. The VRT update operation takes about 10 to 15 minutes.

@montjeffrey
montjeffrey marked this pull request as ready for review November 21, 2026 22:12

@matt-fidd matt-fidd left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

lgtm, will wait for @MatissJanis to have the last say

@MatissJanis

Copy link
Copy Markdown
Member

Thanks!

@MatissJanis
MatissJanis added this pull request to the merge queue Nov 22, 2026
Merged via the queue into actualbudget:master with commit 6aa9dba Nov 22, 2026
52 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

AI generated API Issues with the @actual-app/api package ✨ merged

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: API updateTransaction/deleteTransaction resolve before the change is applied (transfer legs lost)

3 participants