[PR #7150] [CLOSED] Fix amount parser failing on trailing whitespace in CSV imports #21332

Closed
opened 2026-04-14 22:01:44 -05:00 by GiteaMirror · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/actualbudget/actual/pull/7150
Author: @augustdjang
Created: 3/7/2026
Status: Closed

Base: masterHead: fix/trim-amount-parser


📝 Commits (2)

  • aa336c4 Fix amount parser failing on trailing whitespace in CSV imports
  • d578f10 Add release notes for PR #7150

📊 Changes

3 files changed (+15 additions, -0 deletions)

View changed files

📝 packages/loot-core/src/shared/util.test.ts (+8 -0)
📝 packages/loot-core/src/shared/util.ts (+1 -0)
upcoming-release-notes/7150.md (+6 -0)

📄 Description

Closes #7121

Summary

Adds .trim() to looselyParseAmount() to prevent trailing whitespace from breaking the decimal separator detection regex during CSV import.

Root Cause

The regex /[.,]([^.,]{4,9}|[^.,]{1,2})$/ matches against the end of the string. When trailing whitespace is present:

  • "$1,055 " → the comma is misidentified as a decimal separator (,055 = 4 chars, fits {4,9}), parsing as 1.055 → displayed as $1.06
  • "$1,055.00 ".00 is 3 chars (no match for {1,2} or {4,9}), falling through to extractNumbers105500$105,500.00

Changes

  • packages/loot-core/src/shared/util.ts: Added amount = amount.trim() as the first line in looselyParseAmount(). This is the single entry point for all amount parsing (both the desktop import modal and server-side file import funnel through this function).
  • packages/loot-core/src/shared/util.test.ts: Added test cases for leading/trailing whitespace.

Bundle Stats

Bundle Files count Total bundle size % Changed
desktop-client 27 14.89 MB → 14.89 MB (+1.04 kB) +0.01%
loot-core 1 5.82 MB → 5.82 MB (+30 B) +0.00%
api 1 4.43 MB → 4.43 MB (+26 B) +0.00%
View detailed bundle stats

desktop-client

Total

Files count Total bundle size % Changed
27 14.89 MB → 14.89 MB (+1.04 kB) +0.01%
Changeset
File Δ Size
locale/pl.json 📈 +332 B (+0.36%) 89.33 kB → 89.65 kB
locale/uk.json 📈 +712 B (+0.32%) 214.65 kB → 215.35 kB
home/runner/work/actual/actual/packages/loot-core/src/shared/util.ts 📈 +26 B (+0.27%) 9.29 kB → 9.31 kB
View detailed bundle breakdown

Added
No assets were added

Removed
No assets were removed

Bigger

Asset File Size % Changed
static/js/uk.js 214.65 kB → 215.35 kB (+712 B) +0.32%
static/js/pl.js 89.33 kB → 89.65 kB (+332 B) +0.36%
static/js/index.js 9.54 MB → 9.54 MB (+26 B) +0.00%

Smaller
No assets were smaller

Unchanged

Asset File Size % Changed
static/js/indexeddb-main-thread-worker-e59fee74.js 12.94 kB 0%
static/js/workbox-window.prod.es5.js 5.64 kB 0%
static/js/ca.js 187.93 kB 0%
static/js/da.js 106.2 kB 0%
static/js/de.js 179.89 kB 0%
static/js/en-GB.js 7.18 kB 0%
static/js/en.js 170.42 kB 0%
static/js/es.js 174.37 kB 0%
static/js/fr.js 179.41 kB 0%
static/js/it.js 170.98 kB 0%
static/js/nb-NO.js 156.8 kB 0%
static/js/nl.js 113.06 kB 0%
static/js/pt-BR.js 182.89 kB 0%
static/js/th.js 181.58 kB 0%
static/js/resize-observer.js 18.37 kB 0%
static/js/BackgroundImage.js 120.54 kB 0%
static/js/ReportRouter.js 1.16 MB 0%
static/js/narrow.js 638.11 kB 0%
static/js/TransactionList.js 106.22 kB 0%
static/js/wide.js 164.15 kB 0%
static/js/AppliedFilters.js 9.71 kB 0%
static/js/usePayeeRuleCounts.js 10.04 kB 0%
static/js/useTransactionBatchActions.js 13.23 kB 0%
static/js/FormulaEditor.js 1.04 MB 0%

loot-core

Total

Files count Total bundle size % Changed
1 5.82 MB → 5.82 MB (+30 B) +0.00%
Changeset
File Δ Size
home/runner/work/actual/actual/packages/loot-core/src/shared/util.ts 📈 +30 B (+0.38%) 7.67 kB → 7.7 kB
View detailed bundle breakdown

Added

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

Removed

Asset File Size % Changed
kcab.worker.MNtpiHkH.js 5.82 MB → 0 B (-5.82 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
1 4.43 MB → 4.43 MB (+26 B) +0.00%
Changeset
File Δ Size
src/shared/util.ts 📈 +26 B (+0.38%) 6.66 kB → 6.69 kB
View detailed bundle breakdown

Added
No assets were added

Removed
No assets were removed

Bigger

Asset File Size % Changed
bundle.api.js 4.43 MB → 4.43 MB (+26 B) +0.00%

Smaller
No assets were smaller

Unchanged
No assets were unchanged


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/actualbudget/actual/pull/7150 **Author:** [@augustdjang](https://github.com/augustdjang) **Created:** 3/7/2026 **Status:** ❌ Closed **Base:** `master` ← **Head:** `fix/trim-amount-parser` --- ### 📝 Commits (2) - [`aa336c4`](https://github.com/actualbudget/actual/commit/aa336c4bde5b36365d8eefecbc5cc04854b2bf9b) Fix amount parser failing on trailing whitespace in CSV imports - [`d578f10`](https://github.com/actualbudget/actual/commit/d578f1059185b808fe037a0007109516157769b0) Add release notes for PR #7150 ### 📊 Changes **3 files changed** (+15 additions, -0 deletions) <details> <summary>View changed files</summary> 📝 `packages/loot-core/src/shared/util.test.ts` (+8 -0) 📝 `packages/loot-core/src/shared/util.ts` (+1 -0) ➕ `upcoming-release-notes/7150.md` (+6 -0) </details> ### 📄 Description Closes #7121 ## Summary Adds `.trim()` to `looselyParseAmount()` to prevent trailing whitespace from breaking the decimal separator detection regex during CSV import. ## Root Cause The regex `/[.,]([^.,]{4,9}|[^.,]{1,2})$/` matches against the end of the string. When trailing whitespace is present: - `"$1,055 "` → the comma is misidentified as a decimal separator (`,055 ` = 4 chars, fits `{4,9}`), parsing as `1.055` → displayed as `$1.06` - `"$1,055.00 "` → `.00 ` is 3 chars (no match for `{1,2}` or `{4,9}`), falling through to `extractNumbers` → `105500` → `$105,500.00` ## Changes - **`packages/loot-core/src/shared/util.ts`**: Added `amount = amount.trim()` as the first line in `looselyParseAmount()`. This is the single entry point for all amount parsing (both the desktop import modal and server-side file import funnel through this function). - **`packages/loot-core/src/shared/util.test.ts`**: Added test cases for leading/trailing whitespace. <!--- actual-bot-sections ---> <hr /> <!--- bundlestats-action-comment key:combined start ---> ### Bundle Stats Bundle | Files count | Total bundle size | % Changed ------ | ----------- | ----------------- | --------- desktop-client | 27 | 14.89 MB → 14.89 MB (+1.04 kB) | +0.01% loot-core | 1 | 5.82 MB → 5.82 MB (+30 B) | +0.00% api | 1 | 4.43 MB → 4.43 MB (+26 B) | +0.00% <details> <summary>View detailed bundle stats</summary> #### desktop-client **Total** Files count | Total bundle size | % Changed ----------- | ----------------- | --------- 27 | 14.89 MB → 14.89 MB (+1.04 kB) | +0.01% <details> <summary>Changeset</summary> File | Δ | Size ---- | - | ---- `locale/pl.json` | 📈 +332 B (+0.36%) | 89.33 kB → 89.65 kB `locale/uk.json` | 📈 +712 B (+0.32%) | 214.65 kB → 215.35 kB `home/runner/work/actual/actual/packages/loot-core/src/shared/util.ts` | 📈 +26 B (+0.27%) | 9.29 kB → 9.31 kB </details> <details> <summary>View detailed bundle breakdown</summary> <div> **Added** No assets were added **Removed** No assets were removed **Bigger** Asset | File Size | % Changed ----- | --------- | --------- static/js/uk.js | 214.65 kB → 215.35 kB (+712 B) | +0.32% static/js/pl.js | 89.33 kB → 89.65 kB (+332 B) | +0.36% static/js/index.js | 9.54 MB → 9.54 MB (+26 B) | +0.00% **Smaller** No assets were smaller **Unchanged** Asset | File Size | % Changed ----- | --------- | --------- static/js/indexeddb-main-thread-worker-e59fee74.js | 12.94 kB | 0% static/js/workbox-window.prod.es5.js | 5.64 kB | 0% static/js/ca.js | 187.93 kB | 0% static/js/da.js | 106.2 kB | 0% static/js/de.js | 179.89 kB | 0% static/js/en-GB.js | 7.18 kB | 0% static/js/en.js | 170.42 kB | 0% static/js/es.js | 174.37 kB | 0% static/js/fr.js | 179.41 kB | 0% static/js/it.js | 170.98 kB | 0% static/js/nb-NO.js | 156.8 kB | 0% static/js/nl.js | 113.06 kB | 0% static/js/pt-BR.js | 182.89 kB | 0% static/js/th.js | 181.58 kB | 0% static/js/resize-observer.js | 18.37 kB | 0% static/js/BackgroundImage.js | 120.54 kB | 0% static/js/ReportRouter.js | 1.16 MB | 0% static/js/narrow.js | 638.11 kB | 0% static/js/TransactionList.js | 106.22 kB | 0% static/js/wide.js | 164.15 kB | 0% static/js/AppliedFilters.js | 9.71 kB | 0% static/js/usePayeeRuleCounts.js | 10.04 kB | 0% static/js/useTransactionBatchActions.js | 13.23 kB | 0% static/js/FormulaEditor.js | 1.04 MB | 0% </div> </details> --- #### loot-core **Total** Files count | Total bundle size | % Changed ----------- | ----------------- | --------- 1 | 5.82 MB → 5.82 MB (+30 B) | +0.00% <details> <summary>Changeset</summary> File | Δ | Size ---- | - | ---- `home/runner/work/actual/actual/packages/loot-core/src/shared/util.ts` | 📈 +30 B (+0.38%) | 7.67 kB → 7.7 kB </details> <details> <summary>View detailed bundle breakdown</summary> <div> **Added** Asset | File Size | % Changed ----- | --------- | --------- kcab.worker.CVw5oNPx.js | 0 B → 5.82 MB (+5.82 MB) | - **Removed** Asset | File Size | % Changed ----- | --------- | --------- kcab.worker.MNtpiHkH.js | 5.82 MB → 0 B (-5.82 MB) | -100% **Bigger** No assets were bigger **Smaller** No assets were smaller **Unchanged** No assets were unchanged </div> </details> --- #### api **Total** Files count | Total bundle size | % Changed ----------- | ----------------- | --------- 1 | 4.43 MB → 4.43 MB (+26 B) | +0.00% <details> <summary>Changeset</summary> File | Δ | Size ---- | - | ---- `src/shared/util.ts` | 📈 +26 B (+0.38%) | 6.66 kB → 6.69 kB </details> <details> <summary>View detailed bundle breakdown</summary> <div> **Added** No assets were added **Removed** No assets were removed **Bigger** Asset | File Size | % Changed ----- | --------- | --------- bundle.api.js | 4.43 MB → 4.43 MB (+26 B) | +0.00% **Smaller** No assets were smaller **Unchanged** No assets were unchanged </div> </details> </details> <!--- bundlestats-action-comment key:combined end ---> --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
GiteaMirror added the pull-request label 2026-04-14 22:01:44 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/actual#21332