Skip to content

fix: match "is nothing" rule conditions on transactions without a payee or category - #9017

Merged
matt-fidd merged 1 commit into
actualbudget:masterfrom
YasinzHyper:fix/rules-payee-is-nothing
Oct 3, 2026
Merged

matt-fidd merged 1 commit into
actualbudget:masterfrom
YasinzHyper:fix/rules-payee-is-nothing

Conversation

@YasinzHyper

@YasinzHyper YasinzHyper commented Sep 27, 2026 •

Copy link
Copy Markdown
Contributor

Description

When a bank sync or file import brings in a transaction without a payee, the normalized transaction has no payee key at all: resolvePayee in sync.ts returns trans.payee, which is undefined. Condition.eval() treats a missing field as "never matches", so a rule with the condition "payee is nothing" is skipped for exactly the transactions it is meant for. The same rule does work when applied afterwards from the Rules page, because transactions loaded from the database always carry payee: null. The same applies to category.

runRules now treats a missing payee/category as null while matching, and drops the field again afterwards if it is still null, so the returned transaction keeps the same shape as the input. Condition itself is unchanged, so no other operators or fields are affected.

#7531 took the same approach and was approved in review, but went stale before it was merged.

Related issue(s)

Fixes #5724

Testing

Automated (from the repo root, Windows 11):

  • yarn workspace @actual-app/core run test:node src/server/transactions/transaction-rules.test.ts src/server/rules/index.test.ts – 147 passed. The two new tests in transaction-rules.test.ts fail without the change to transaction-rules.ts and pass with it.
  • yarn typecheck – all workspaces pass.
  • oxfmt --check and oxlint --type-aware on the two changed files – clean.
  • yarn test – all workspaces pass locally except two Windows-only environment failures that reproduce identically on master without this change: loot-core/src/server/main.test.ts cannot delete mocks/files/budgets/test-budget/db.sqlite between tests (EBUSY, then EEXIST on the next mkdir), and sync-server reports all 606 tests passed but exits non-zero with EBUSY deleting test-server-files/account.sqlite.
  • CI on this PR: every check passes, including the full test job across all workspaces, typecheck, lint, the functional and desktop e2e suites and the visual regression shards.

To reproduce on master (I verified the behaviour through the unit tests above, not through the UI):

  1. Create a rule with the condition payee is and the value left empty ("nothing"), and the action set notes to no payee.
  2. Import a CSV/OFX file (or run a bank sync) containing a transaction with an empty payee.
  3. The imported transaction does not get the note. Applying the rule from the Rules page afterwards does add it.
  4. With this change, the note is added during the import.

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

AI disclosure: this change was prepared with AI assistance (Claude Code); follow-up commits and replies on this PR may be as well.


Bundle Stats

Bundle Files count Total bundle size % Changed
desktop-client 42 13.96 MB → 13.96 MB (+878 B) +0.01%
loot-core 1 4.65 MB → 4.65 MB (+387 B) +0.01%
api 2 3.87 MB → 3.87 MB (+381 B) +0.01%
cli 1 8.02 MB 0%
crdt 1 11.16 kB 0%
View detailed bundle stats

desktop-client

Total

Files count Total bundle size % Changed
42 13.96 MB → 13.96 MB (+878 B) +0.01%
Changeset
File Δ Size
locale/zh-Hans.json 📈 +523 B (+0.48%) 106.8 kB → 107.31 kB
locale/uk.json 📈 +261 B (+0.12%) 211.1 kB → 211.35 kB
locale/en.json 📈 +94 B (+0.03%) 271.45 kB → 271.54 kB
View detailed bundle breakdown

Added
No assets were added

Removed
No assets were removed

Bigger

Asset File Size % Changed
static/js/zh-Hans.js 106.8 kB → 107.31 kB (+523 B) +0.48%
static/js/uk.js 211.1 kB → 211.35 kB (+261 B) +0.12%
static/js/en.js 271.45 kB → 271.54 kB (+94 B) +0.03%

Smaller
No assets were smaller

Unchanged

Asset File Size % Changed
static/js/index.js 1.75 MB 0%
static/js/BackgroundImage.js 121.09 kB 0%
static/js/DateSelect.js 2.37 MB 0%
static/js/FormulaEditor.js 767.24 kB 0%
static/js/ManageRules.js 71.66 kB 0%
static/js/NotesTagFormatter.js 25.94 kB 0%
static/js/PayeeRuleCountLabel.js 12.81 kB 0%
static/js/ReportRouter.js 1.54 MB 0%
static/js/ScheduleEditForm.js 75.41 kB 0%
static/js/SchedulesTable.js 171.25 kB 0%
static/js/TourHost.js 169.22 kB 0%
static/js/TourProvider.js 1.54 kB 0%
static/js/TransactionEdit.js 219.59 kB 0%
static/js/TransactionList.js 166.98 kB 0%
static/js/Value.js 1.79 MB 0%
static/js/bootstrapHyperFormula.js 302 B 0%
static/js/ca.js 170.64 kB 0%
static/js/client.js 452.05 kB 0%
static/js/columns.js 673.28 kB 0%
static/js/de.js 186.43 kB 0%
static/js/en-GB.js 13.69 kB 0%
static/js/es.js 182.1 kB 0%
static/js/fr.js 178.59 kB 0%
static/js/indexeddb-main-thread-worker-e59fee74.js 13.46 kB 0%
static/js/it.js 151.91 kB 0%
static/js/months.js 591.12 kB 0%
static/js/narrow.js 290.52 kB 0%
static/js/nb-NO.js 135.89 kB 0%
static/js/nl.js 151.78 kB 0%
static/js/pl.js 136.51 kB 0%
static/js/pt-BR.js 178.74 kB 0%
static/js/ru.js 211 kB 0%
static/js/theme.js 31.68 kB 0%
static/js/useFormatList.js 10.4 kB 0%
static/js/useLocalPref.js 97.2 kB 0%
static/js/useReducedMotion.js 594 B 0%
static/js/wide.js 274.53 kB 0%
static/js/workbox-window.prod.es5.js 7.21 kB 0%
static/js/zh-Hant.js 130.92 kB 0%

loot-core

Total

Files count Total bundle size % Changed
1 4.65 MB → 4.65 MB (+387 B) +0.01%
Changeset
File Δ Size
home/runner/work/actual/actual/packages/loot-core/src/server/transactions/transaction-rules.ts 📈 +387 B (+1.60%) 23.62 kB → 24 kB
View detailed bundle breakdown

Added

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

Removed

Asset File Size % Changed
kcab.worker.Dv8r7c1b.js 4.65 MB → 0 B (-4.65 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 3.87 MB → 3.87 MB (+381 B) +0.01%
Changeset
File Δ Size
home/runner/work/actual/actual/packages/loot-core/src/server/transactions/transaction-rules.ts 📈 +381 B (+1.57%) 23.67 kB → 24.04 kB
View detailed bundle breakdown

Added
No assets were added

Removed
No assets were removed

Bigger

Asset File Size % Changed
index.js 3.87 MB → 3.87 MB (+381 B) +0.01%

Smaller
No assets were smaller

Unchanged

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

cli

Total

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

crdt

Total

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

@actual-github-bot actual-github-bot Bot changed the title fix: match "is nothing" rule conditions on transactions without a payee or category [WIP] fix: match "is nothing" rule conditions on transactions without a payee or category Sep 27, 2026
@netlify

netlify Bot commented Sep 27, 2026 •

Copy link
Copy Markdown

✅ Deploy Preview for actualbudget ready!

Name Link
🔨 Latest commit e979be2
🔍 Latest deploy log https://app.netlify.com/projects/actualbudget/deploys/6ab8afb9941913000872cf46
😎 Deploy Preview https://deploy-preview-9017.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.

@coderabbitai

coderabbitai Bot commented Sep 27, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

Navigate logical layers of code changes, visualize relationships, and explore their blast radius.

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository: actualbudget/actual/.coderabbit.yaml

Review profile: CHILL

Plan: Advanced

Run ID: 37a07632-98ff-4625-8df7-d519266b1b87

📥 Commits

Reviewing files that changed from the base of the PR and between bfa850c and e979be2.

📒 Files selected for processing (3)
  • packages/loot-core/src/server/transactions/transaction-rules.test.ts
  • packages/loot-core/src/server/transactions/transaction-rules.ts
  • upcoming-release-notes/rules-payee-is-nothing.md

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 9 remain after this review.


📝 Walkthrough

Walkthrough

runRules treats omitted payee and category fields as null during rule matching. After finalization, it removes those fields if they remain null. Tests cover null-condition matches, notes actions, and a later rule setting a payee.

Changes

Null transaction rule conditions

Layer / File(s) Summary
Normalize, match, and restore transaction fields
packages/loot-core/src/server/transactions/transaction-rules.ts, packages/loot-core/src/server/transactions/transaction-rules.test.ts, upcoming-release-notes/rules-payee-is-nothing.md
runRules normalizes omitted payee and category fields to null before rule preparation. It removes each field after finalization only if the value is still null. Tests cover matching null conditions and retaining notes when a later rule sets a payee. The release note describes the reported mismatch for synced transactions.

Priority: ➖ Normal

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

Change: Bug fix · Severity of issue fixed: Medium

Merge Risk: ⚪ Minimal · up to e979b

The change addresses automatic matching for transactions without a payee or category. No actionable merge-blocking risk is identified; merge after normal checks.

Security Architecture Review

Security architecture risk: 🟡 Moderate · up to e979b

Transactions with no payee or category can now trigger additional automatic rules. That includes potentially more than the intended “is nothing” rules, and the resulting changes can be saved during an import. No new access path was identified, but the full effect on rule selection and recovery is not established.

Retained concerns

  • Medium · security · inferred: Normalizing missing payee and category values can also make an evaluated “is not [value]” rule match, beyond the intended “is nothing” case. Its actions may then affect a transaction saved by the existing import flow.
Security review details

Security Blast Radius

  • inferred — The plausible integrity impact is within transactions processed by existing rule and import flows, including bank or file inputs with missing nullable fields. The evidence does not establish cross-account or cross-tenant access.

Security Findings and Attack Paths

  • inferred — An imported transaction lacking payee or category can make a candidate negated condition evaluate true where undefined previously failed evaluation. If that rule applies an action, the existing import flow can save the changed result; candidate-index reachability for every such rule is not verified.

Trust Boundaries and Controls

  • observed — This change does not add a rules handler or a transaction-write path. The inspected handler only delegates to runRules, while import consumers retain responsibility for persistence.

Resilience and Maintainability Implications

  • inferred — Per-call copying limits contamination of the caller’s top-level transaction on failure or repetition. Whether payee creation newly reached by a matching rule rolls back with a later import failure remains unverified.
🚥 Pre-merge checks | ✅ 4
✅ Passed checks (4 passed)
Check name Status Explanation
Linked Issues check ✅ Passed Issue [#5724] requires automatic rule matching for transactions without a payee. runRules normalizes an omitted payee to null before rule evaluation and removes it after evaluation when it remai…
Out of Scope Changes check ✅ Passed The changes stay within the rule-matching fix. The source change handles omitted nullable rule fields, the tests cover the payee and category behavior, and the release note documents the same bug fix.…
Title check ✅ Passed The title clearly identifies the fix for “is nothing” rules on transactions without a payee or category.
Description check ✅ Passed The description explains the missing-field matching issue, the change, and how it was tested.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create a new PR

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

Comment @coderabbitai help to get the list of available commands.

@YasinzHyper YasinzHyper changed the title [WIP] fix: match "is nothing" rule conditions on transactions without a payee or category fix: match "is nothing" rule conditions on transactions without a payee or category Sep 27, 2026

@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.

This makes sense, thanks for the change. I have run it against my rules and I didn't see any behaviour I consider breaking. It's worth remembering this though, just in case users start to see issues with rule application

@matt-fidd
matt-fidd added this pull request to the merge queue Oct 3, 2026
Merged via the queue into actualbudget:master with commit b490e3e Oct 3, 2026
51 checks passed
flafleur pushed a commit to flafleur/actual that referenced this pull request Oct 21, 2026
RafaelEspino pushed a commit to RafaelEspino/actual that referenced this pull request Oct 28, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: Rule with payee is "nothing" never matching

2 participants