[GH-ISSUE #3235] [Bug]: Rule with regular expressions not applying to imported transactions #15559

Closed
opened 2026-04-14 18:34:54 -05:00 by GiteaMirror · 4 comments
Owner

Originally created by @jeffwlawson on GitHub (Aug 11, 2024).
Original GitHub issue: https://github.com/actualbudget/actual/issues/3235

Verified issue does not already exist?

  • I have searched and found no existing issue
  • I will be providing steps how to reproduce the bug (in most cases this will also mean uploading a demo budget file)

What happened?

I've created a rule for when the imported payee matches a set of criteria. I'm using the regex caret '^' to make sure the string is at the beginning of the imported payee name. I'm using SimpleFIN to import new transactions, but these rules are not automatically applying to the new transactions.

However, if I go back to look at the rule, it shows that these transactions do match, they just aren't getting applied for some reason.

image

For all other types of rules not using this syntax, they seem to be applying properly. Am I doing something wrong?

Where are you hosting Actual?

Docker

What browsers are you seeing the problem on?

Firefox, Desktop App (Electron)

Operating System

Windows 11

Originally created by @jeffwlawson on GitHub (Aug 11, 2024). Original GitHub issue: https://github.com/actualbudget/actual/issues/3235 ### Verified issue does not already exist? - [X] I have searched and found no existing issue - [X] I will be providing steps how to reproduce the bug (in most cases this will also mean uploading a demo budget file) ### What happened? I've created a rule for when the imported payee matches a set of criteria. I'm using the regex caret '^' to make sure the string is at the beginning of the imported payee name. I'm using SimpleFIN to import new transactions, but these rules are not automatically applying to the new transactions. However, if I go back to look at the rule, it shows that these transactions _do match_, they just aren't getting applied for some reason. ![image](https://github.com/user-attachments/assets/c4f0b85d-5baa-49d1-a284-83757f243d02) For all other types of rules not using this syntax, they seem to be applying properly. Am I doing something wrong? ### Where are you hosting Actual? Docker ### What browsers are you seeing the problem on? Firefox, Desktop App (Electron) ### Operating System Windows 11
GiteaMirror added the bug label 2026-04-14 18:34:54 -05:00
Author
Owner

@natrlhy commented on GitHub (Aug 14, 2024):

I am also seeing this as well when using matches

<!-- gh-comment-id:2289487122 --> @natrlhy commented on GitHub (Aug 14, 2024): I am also seeing this as well when using `matches`
Author
Owner

@jameshurst commented on GitHub (Aug 14, 2024):

I was also experiencing this issue and was able to fix it with the following patch. The issue is that Condition.eval does not have support for the 'matches' operator. I'm assuming to turn this into a PR it would need accompanying tests and exceptions thrown by new RegExp may want to be handled.

diff --git a/packages/loot-core/src/server/accounts/rules.ts b/packages/loot-core/src/server/accounts/rules.ts
index a72c8b6..ca50f7f 100644
--- a/packages/loot-core/src/server/accounts/rules.ts
+++ b/packages/loot-core/src/server/accounts/rules.ts
@@ -419,6 +419,11 @@ export class Condition {
           );
         }
         return fieldValue <= extractValue(this.value);
+      case 'matches':
+        if (fieldValue === null) {
+          return false;
+        }
+        return new RegExp(this.value).test(fieldValue);
       default:
     }
 
<!-- gh-comment-id:2290076347 --> @jameshurst commented on GitHub (Aug 14, 2024): I was also experiencing this issue and was able to fix it with the following patch. The issue is that `Condition.eval` does not have support for the `'matches'` operator. I'm assuming to turn this into a PR it would need accompanying tests and exceptions thrown by `new RegExp` may want to be handled. ```diff diff --git a/packages/loot-core/src/server/accounts/rules.ts b/packages/loot-core/src/server/accounts/rules.ts index a72c8b6..ca50f7f 100644 --- a/packages/loot-core/src/server/accounts/rules.ts +++ b/packages/loot-core/src/server/accounts/rules.ts @@ -419,6 +419,11 @@ export class Condition { ); } return fieldValue <= extractValue(this.value); + case 'matches': + if (fieldValue === null) { + return false; + } + return new RegExp(this.value).test(fieldValue); default: } ```
Author
Owner

@psybers commented on GitHub (Aug 18, 2024):

I was also experiencing this issue and was able to fix it with the following patch. The issue is that Condition.eval does not have support for the 'matches' operator. I'm assuming to turn this into a PR it would need accompanying tests and exceptions thrown by new RegExp may want to be handled.

diff --git a/packages/loot-core/src/server/accounts/rules.ts b/packages/loot-core/src/server/accounts/rules.ts
index a72c8b6..ca50f7f 100644
--- a/packages/loot-core/src/server/accounts/rules.ts
+++ b/packages/loot-core/src/server/accounts/rules.ts
@@ -419,6 +419,11 @@ export class Condition {
           );
         }
         return fieldValue <= extractValue(this.value);
+      case 'matches':
+        if (fieldValue === null) {
+          return false;
+        }
+        return new RegExp(this.value).test(fieldValue);
       default:
     }
 

Thanks for this! I PR'd it as #3287 and added some tests. You should be co-authored.

<!-- gh-comment-id:2295340541 --> @psybers commented on GitHub (Aug 18, 2024): > I was also experiencing this issue and was able to fix it with the following patch. The issue is that `Condition.eval` does not have support for the `'matches'` operator. I'm assuming to turn this into a PR it would need accompanying tests and exceptions thrown by `new RegExp` may want to be handled. > > ```diff > diff --git a/packages/loot-core/src/server/accounts/rules.ts b/packages/loot-core/src/server/accounts/rules.ts > index a72c8b6..ca50f7f 100644 > --- a/packages/loot-core/src/server/accounts/rules.ts > +++ b/packages/loot-core/src/server/accounts/rules.ts > @@ -419,6 +419,11 @@ export class Condition { > ); > } > return fieldValue <= extractValue(this.value); > + case 'matches': > + if (fieldValue === null) { > + return false; > + } > + return new RegExp(this.value).test(fieldValue); > default: > } > > ``` Thanks for this! I PR'd it as #3287 and added some tests. You should be co-authored.
Author
Owner

@gotofritz commented on GitHub (Jan 11, 2025):

Was there a regression on this? Because I have just downloaded the latest edge docker images and the bug is still there. I checked out the latest version (25.1.0) and run the server locally, same thing.

Never mind, I didn't realize that there is a contains which ignores regexes and a matches which applies them

<!-- gh-comment-id:2585471056 --> @gotofritz commented on GitHub (Jan 11, 2025): ~~Was there a regression on this? Because I have just downloaded the latest edge docker images and the bug is still there. I checked out the latest version (25.1.0) and run the server locally, same thing.~~ Never mind, I didn't realize that there is a `contains` which ignores regexes and a `matches` which applies them
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/actual#15559