[PR #6491] Fix crash when switching filter operators between single and multi-value modes #6560

Closed
opened 2026-02-28 21:30:01 -06:00 by GiteaMirror · 0 comments
Owner

Original Pull Request: https://github.com/actualbudget/actual/pull/6491

State: closed
Merged: Yes


Plan to Fix Filter Crash Issue

  • Explore repository structure and understand the issue
  • Identify the root cause: When switching from "is" to "one of", the value is not converted from a single value to an array
  • Create a test to verify the fix
  • Fix the updateFilterReducer.ts to convert single values to arrays when switching to "oneOf" or "notOneOf" operators
  • Verify the fix works correctly (tests passing)
  • Run full test suite to ensure no regressions (all web tests pass)
  • Run type checking and linting (both pass)
  • Handle switching from 'one of' to 'is' by keeping first element
  • Use strict comparison operators (===)
  • Code review completed with no issues
  • Address PR feedback: remove notes test, improve single-value preservation

Fix Summary:

This PR fixes a crash that occurred when editing report filters by changing operators between single-value and multi-value types.

Changes Made:

  1. Bidirectional conversion support:
    • Switching TO "oneOf"/"notOneOf": Converts single values to arrays, null/undefined to empty arrays
    • Switching FROM "oneOf"/"notOneOf": Keeps the first element if array has values, otherwise null
    • Single values are preserved when switching between single-value operators (e.g., 'is' to 'contains')
  2. Code quality: Uses strict comparison operators (===) throughout
  3. Comprehensive testing: 9 unit tests covering all conversion scenarios

Testing: All tests pass, type checking and linting pass, no regressions detected.

Original prompt

This section details on the original issue you should resolve

<issue_title>[Bug]: App crashes when editing report field from "is" (with value) to "one of"</issue_title>
<issue_description>### Verified issue does not already exist?

  • I have searched and found no existing issue

What happened?

I've noticed Actual consistently crashes when editing a report filter when moving from is to one of and the is field is set to a value. Haven't tested all the combinations, but guessing other changes can trigger a similar problem. Example screenshots below.

TypeError: l.map is not a function at Lot...
Image Image

How can we reproduce the issue?

How can we reproduce the issue?

Go to a report filter of type account, category, or notes (interestingly, payee does not have this bug), and set a value under is or is not and then change to one of or not one of. (I have not tested all the combinations, but these ones for sure cause the crash.)

Where are you hosting Actual?

Docker

What browsers are you seeing the problem on?

Chrome, Other, Firefox

Operating System

Windows 10</issue_description>

Comments on the Issue (you are @copilot in this section)


Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

Summary by CodeRabbit

  • Bug Fixes
    • Improved filter operator switching to intelligently preserve and convert filter values based on the selected operator type. When switching between single-value operators (is, contains) and multi-value operators (oneOf), values are now properly handled rather than unexpectedly cleared, with better support for edge cases.

✏️ Tip: You can customize this high-level summary in your review settings.


Note

Fixes filter operator switching by normalizing value between single- and multi-select modes to prevent crashes.

  • Updates updateFilterReducer to:
    • When switching to single-value ops (is, isNot, contains, etc.), convert arrays to first element or null if empty
    • When switching to multi-value ops (oneOf, notOneOf), convert single values to arrays and null/undefined to []
  • Adds unit tests (updateFilterReducer.test.ts) covering bidirectional conversions and edge cases (empty arrays, nulls, preservation between single-value ops)
  • Adds release note entry documenting the bugfix

Written by Cursor Bugbot for commit fe0bf2cf9d. This will update automatically on new commits. Configure here.

**Original Pull Request:** https://github.com/actualbudget/actual/pull/6491 **State:** closed **Merged:** Yes --- ## Plan to Fix Filter Crash Issue - [x] Explore repository structure and understand the issue - [x] Identify the root cause: When switching from "is" to "one of", the value is not converted from a single value to an array - [x] Create a test to verify the fix - [x] Fix the `updateFilterReducer.ts` to convert single values to arrays when switching to "oneOf" or "notOneOf" operators - [x] Verify the fix works correctly (tests passing) - [x] Run full test suite to ensure no regressions (all web tests pass) - [x] Run type checking and linting (both pass) - [x] Handle switching from 'one of' to 'is' by keeping first element - [x] Use strict comparison operators (===) - [x] Code review completed with no issues - [x] Address PR feedback: remove notes test, improve single-value preservation **Fix Summary**: This PR fixes a crash that occurred when editing report filters by changing operators between single-value and multi-value types. **Changes Made**: 1. **Bidirectional conversion support**: - Switching TO "oneOf"/"notOneOf": Converts single values to arrays, null/undefined to empty arrays - Switching FROM "oneOf"/"notOneOf": Keeps the first element if array has values, otherwise null - Single values are preserved when switching between single-value operators (e.g., 'is' to 'contains') 2. **Code quality**: Uses strict comparison operators (===) throughout 3. **Comprehensive testing**: 9 unit tests covering all conversion scenarios **Testing**: All tests pass, type checking and linting pass, no regressions detected. <!-- START COPILOT ORIGINAL PROMPT --> <details> <summary>Original prompt</summary> > > ---- > > *This section details on the original issue you should resolve* > > <issue_title>[Bug]: App crashes when editing report field from "is" (with value) to "one of"</issue_title> > <issue_description>### Verified issue does not already exist? > > - [x] I have searched and found no existing issue > > ### What happened? > > I've noticed Actual consistently crashes when editing a report filter when moving from `is` to `one of` and the is field is set to a value. Haven't tested all the combinations, but guessing other changes can trigger a similar problem. Example screenshots below. > ``` > TypeError: l.map is not a function at Lot... > ``` > > <img width="255" height="197" alt="Image" src="https://github.com/user-attachments/assets/92d3fc8e-b8b5-40bb-bbb9-4229adaeb718" /> > > <img width="566" height="250" alt="Image" src="https://github.com/user-attachments/assets/a9d013b3-349c-4f18-a7fc-6a19053c2ef2" /> > > ### How can we reproduce the issue? > > How can we reproduce the issue? > > Go to a report filter of type account, category, or notes (interestingly, payee does not have this bug), and set a value under `is` or `is not` and then change to `one of` or `not one of`. (I have not tested all the combinations, but these ones for sure cause the crash.) > > ### Where are you hosting Actual? > > Docker > > ### What browsers are you seeing the problem on? > > Chrome, Other, Firefox > > ### Operating System > > Windows 10</issue_description> > > ## Comments on the Issue (you are @copilot in this section) > > <comments> > </comments> > </details> <!-- START COPILOT CODING AGENT SUFFIX --> - Fixes actualbudget/actual#6452 <!-- START COPILOT CODING AGENT TIPS --> --- ✨ Let Copilot coding agent [set things up for you](https://github.com/actualbudget/actual/issues/new?title=✨+Set+up+Copilot+instructions&body=Configure%20instructions%20for%20this%20repository%20as%20documented%20in%20%5BBest%20practices%20for%20Copilot%20coding%20agent%20in%20your%20repository%5D%28https://gh.io/copilot-coding-agent-tips%29%2E%0A%0A%3COnboard%20this%20repo%3E&assignees=copilot) — coding agent works faster and does higher quality work when set up for your repo. <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit * **Bug Fixes** * Improved filter operator switching to intelligently preserve and convert filter values based on the selected operator type. When switching between single-value operators (is, contains) and multi-value operators (oneOf), values are now properly handled rather than unexpectedly cleared, with better support for edge cases. <sub>✏️ Tip: You can customize this high-level summary in your review settings.</sub> <!-- end of auto-generated comment: release notes by coderabbit.ai --> <!-- CURSOR_SUMMARY --> --- > [!NOTE] > Fixes filter operator switching by normalizing `value` between single- and multi-select modes to prevent crashes. > > - Updates `updateFilterReducer` to: > - When switching to single-value ops (`is`, `isNot`, `contains`, etc.), convert arrays to first element or `null` if empty > - When switching to multi-value ops (`oneOf`, `notOneOf`), convert single values to arrays and `null/undefined` to `[]` > - Adds unit tests (`updateFilterReducer.test.ts`) covering bidirectional conversions and edge cases (empty arrays, nulls, preservation between single-value ops) > - Adds release note entry documenting the bugfix > > <sup>Written by [Cursor Bugbot](https://cursor.com/dashboard?tab=bugbot) for commit fe0bf2cf9d520f580026258dc2ada1270429c0a4. This will update automatically on new commits. Configure [here](https://cursor.com/dashboard?tab=bugbot).</sup> <!-- /CURSOR_SUMMARY -->
GiteaMirror added the pull-request label 2026-02-28 21:30:01 -06:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/actual#6560