Skip to content

feat(reports): scoped ErrorBoundaries for individual report routes - #7658

Merged
MatissJanis merged 5 commits into
actualbudget:masterfrom
tmchow:osc/7391-error-boundaries-reports
Jun 5, 2026
Merged

MatissJanis merged 5 commits into
actualbudget:masterfrom
tmchow:osc/7391-error-boundaries-reports

Conversation

@tmchow

@tmchow tmchow commented Apr 29, 2026 •

Copy link
Copy Markdown
Contributor

Description

This PR adds scoped ErrorBoundary wrappers around each individual report route in ReportRouter.tsx (NetWorth, CashFlow, Spending, CustomReport, Calendar, Formula, Summary, Crossover, AgeOfMoney, BudgetAnalysis, Sankey).

Today, a render error inside any of those report views bubbles up to the top-level FatalError boundary in App.tsx and crashes the whole app to the fatal-error screen. Wrapping each route in a FeatureErrorFallback boundary contains the failure to that one report — the rest of the app keeps working.

This is the next slice of #7391's table; the prior PRs (#7382 dashboard widgets, #7437 rules, #7497 budget/account/transactions/schedules/sidebar) already handled their respective areas. The dashboard view uses Overview.tsx's per-widget boundaries so it's intentionally not wrapped here.

The pattern matches the one already used for /rules routes in FinancesApp.tsx:

<Route
  path="/net-worth"
  element={
    <ErrorBoundary FallbackComponent={FeatureErrorFallback} resetKeys={[location.pathname]}>
      <NetWorth />
    </ErrorBoundary>
  }
/>

The resetKeys={[location.pathname]} lets the boundary auto-reset when the user navigates to a different report.

Related issue(s)

Relates to #7391

Testing

Manual:

  • Temporarily threw inside one of the wrapped report components and confirmed only that report shows the FeatureErrorFallback; the sidebar, header, and account list keep rendering.
  • Navigated between reports with the boundary tripped and confirmed the boundary resets on pathname change.
  • Removed test errors, ran yarn oxlint --type-aware --quiet and yarn oxfmt --check against the changed file — clean.

Checklist

  • Release notes added (see link above)
  • No obvious regressions in affected areas
  • Self-review has been performed - I understand what each change in the code does and why it is needed

Bundle Stats

Bundle Files count Total bundle size % Changed
desktop-client 37 14.05 MB → 14.06 MB (+2.28 kB) +0.02%
loot-core 1 5.28 MB 0%
api 2 3.86 MB 0%
cli 1 7.97 MB 0%
crdt 1 11.12 kB 0%
View detailed bundle stats

desktop-client

Total

Files count Total bundle size % Changed
37 14.05 MB → 14.06 MB (+2.28 kB) +0.02%
Changeset
File Δ Size
src/components/reports/ReportRouter.tsx 📈 +2.28 kB (+29.63%) 7.68 kB → 9.96 kB
View detailed bundle breakdown

Added
No assets were added

Removed
No assets were removed

Bigger

Asset File Size % Changed
static/js/ReportRouter.js 1.26 MB → 1.26 MB (+2.28 kB) +0.18%

Smaller
No assets were smaller

Unchanged

Asset File Size % Changed
static/js/index.js 1.56 MB 0%
static/js/BackgroundImage.js 121.09 kB 0%
static/js/FormulaEditor.js 962.55 kB 0%
static/js/ManageRules.js 46.6 kB 0%
static/js/PayeeRuleCountLabel.js 7.33 kB 0%
static/js/ScheduleEditForm.js 146.44 kB 0%
static/js/SchedulesTable.js 202.7 kB 0%
static/js/TransactionEdit.js 90.63 kB 0%
static/js/TransactionList.js 85.81 kB 0%
static/js/Value.js 5.08 MB 0%
static/js/_baseIsEqual.js 98.38 kB 0%
static/js/ca.js 186.26 kB 0%
static/js/client.js 451.37 kB 0%
static/js/da.js 100.8 kB 0%
static/js/de.js 170.65 kB 0%
static/js/en-GB.js 9.25 kB 0%
static/js/en.js 200.02 kB 0%
static/js/es.js 178.21 kB 0%
static/js/extends.js 508.06 kB 0%
static/js/fr.js 178.06 kB 0%
static/js/indexeddb-main-thread-worker-e59fee74.js 13.46 kB 0%
static/js/it.js 164.53 kB 0%
static/js/narrow.js 364.2 kB 0%
static/js/nb-NO.js 147.72 kB 0%
static/js/nl.js 106.82 kB 0%
static/js/pt-BR.js 187.97 kB 0%
static/js/resize-observer.js 18.06 kB 0%
static/js/th.js 174.31 kB 0%
static/js/theme.js 31.88 kB 0%
static/js/toString.js 705.14 kB 0%
static/js/uk.js 208.65 kB 0%
static/js/useFormatList.js 2.52 kB 0%
static/js/useTransactionBatchActions.js 9.71 kB 0%
static/js/wide.js 298.88 kB 0%
static/js/workbox-window.prod.es5.js 7.33 kB 0%
static/js/zh-Hans.js 116.84 kB 0%

loot-core

Total

Files count Total bundle size % Changed
1 5.28 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
kcab.worker.BkkH_8jr.js 5.28 MB 0%

api

Total

Files count Total bundle size % Changed
2 3.86 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
index.js 3.86 MB 0%
models.js 0 B 0%

cli

Total

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

crdt

Total

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

@actual-github-bot actual-github-bot Bot changed the title feat(reports): scoped ErrorBoundaries for individual report routes [WIP] feat(reports): scoped ErrorBoundaries for individual report routes Apr 29, 2026
@netlify

netlify Bot commented Apr 29, 2026 •

Copy link
Copy Markdown

✅ Deploy Preview for actualbudget ready!

Name Link
🔨 Latest commit bae298c
🔍 Latest deploy log https://app.netlify.com/projects/actualbudget/deploys/6a2334869ede8500081440ad
😎 Deploy Preview https://deploy-preview-7658.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
  • ✅ 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.

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 Apr 29, 2026 •

Copy link
Copy Markdown
Contributor

Complex PR? Review this PR in Change Stack to move by importance, not file order.

Review Change Stack

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 8f72ca2d-dcb1-4f30-b22d-1d51456ddb36

📥 Commits

Reviewing files that changed from the base of the PR and between 1ac8b21 and bae298c.

📒 Files selected for processing (2)
  • packages/desktop-client/src/components/reports/ReportRouter.tsx
  • upcoming-release-notes/7658.md

📝 Walkthrough

Walkthrough

ReportRouter adds an internal ReportBoundary that uses useLocation() and wraps all non-dashboard report routes in an ErrorBoundary configured with FeatureErrorFallback and resetKeys tied to location.pathname; dashboard routes remain unwrapped.

Changes

Report Router Error Boundaries

Layer / File(s) Summary
Imports / Types
packages/desktop-client/src/components/reports/ReportRouter.tsx
Replace default React import with type-only import, add useLocation, ErrorBoundary, and FeatureErrorFallback.
ReportBoundary
packages/desktop-client/src/components/reports/ReportRouter.tsx
Add internal ReportBoundary component that calls useLocation() and renders children inside ErrorBoundary with FallbackComponent={FeatureErrorFallback} and resetKeys={[location.pathname]}.
Routing Integration
packages/desktop-client/src/components/reports/ReportRouter.tsx
Wrap non-dashboard report routes (e.g., /net-worth, /cash-flow, /custom, /spending, /budget-analysis, /summary, /calendar, /formula, feature-flagged /crossover, /age-of-money, and their /:id variants) with ReportBoundary.
Sankey Routes
packages/desktop-client/src/components/reports/ReportRouter.tsx
Wrap /sankey and /sankey/:id routes with ReportBoundary.
Release Notes
upcoming-release-notes/7658.md
Add maintenance release note documenting scoped error boundaries around individual report routes.

Sequence Diagram

sequenceDiagram
  participant Router as ReportRouter
  participant Loc as useLocation
  participant Boundary as ReportBoundary/ErrorBoundary
  participant Report as ReportRouteComponent
  participant Fallback as FeatureErrorFallback

  Router->>Loc: read location.pathname
  Router->>Boundary: render route element inside ReportBoundary
  Boundary->>Boundary: set resetKeys = [location.pathname]
  Boundary->>Report: render report component
  alt report component throws
    Boundary->>Fallback: render FeatureErrorFallback
  end
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related issues

Suggested reviewers

  • MatissJanis

Poem

I nibble bugs with gentle care,
Each route wrapped safe, no wild scare,
Boundaries stitch where errors roam,
Reports stay cozy, all at home,
Hopping cheers for stable chrome. 🐰

🚥 Pre-merge checks | ✅ 4
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately describes the main change: adding scoped ErrorBoundaries to individual report routes in the reports area.
Description check ✅ Passed The description is comprehensive and directly related to the changeset, explaining the motivation, implementation pattern, testing, and related issue.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Warning

There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure.

🔧 ESLint

If the error stems from missing dependencies, add them to the package.json file. For unrecoverable errors (e.g., due to private dependencies), disable the tool in the CodeRabbit configuration.

ESLint install failed. For unrecoverable errors, disable the tool in CodeRabbit configuration.


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 and usage tips.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🧹 Nitpick comments (1)
packages/desktop-client/src/components/reports/ReportRouter.tsx (1)

32-287: Reduce boundary boilerplate to a small helper to lower drift risk.

The same ErrorBoundary wrapper is repeated for every report route. A tiny helper will keep future route additions safer and easier to review.

Refactor sketch
 export function ReportRouter() {
   const location = useLocation();
+  function withReportBoundary(element: React.ReactElement) {
+    return (
+      <ErrorBoundary
+        FallbackComponent={FeatureErrorFallback}
+        resetKeys={[location.pathname]}
+      >
+        {element}
+      </ErrorBoundary>
+    );
+  }

   return (
     <Routes>
@@
-      <Route
-        path="/net-worth"
-        element={
-          <ErrorBoundary
-            FallbackComponent={FeatureErrorFallback}
-            resetKeys={[location.pathname]}
-          >
-            <NetWorth />
-          </ErrorBoundary>
-        }
-      />
+      <Route path="/net-worth" element={withReportBoundary(<NetWorth />)} />
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@packages/desktop-client/src/components/reports/ReportRouter.tsx` around lines
32 - 287, The routes in ReportRouter.tsx repeat the same ErrorBoundary wrapper
for every report (ErrorBoundary, FallbackComponent=FeatureErrorFallback,
resetKeys={[location.pathname]}), which is boilerplate and error-prone; create a
small helper function or component (e.g., wrapWithFeatureBoundary or
FeatureRouteWrapper) that accepts a report component (NetWorth, Crossover,
AgeOfMoney, CashFlow, CustomReport, Spending, BudgetAnalysis, Summary, Calendar,
Formula, Sankey) and returns the element already wrapped by ErrorBoundary with
FallbackComponent and resetKeys set to [location.pathname], then replace each
route element with a call to that helper to remove duplication and keep behavior
identical.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Nitpick comments:
In `@packages/desktop-client/src/components/reports/ReportRouter.tsx`:
- Around line 32-287: The routes in ReportRouter.tsx repeat the same
ErrorBoundary wrapper for every report (ErrorBoundary,
FallbackComponent=FeatureErrorFallback, resetKeys={[location.pathname]}), which
is boilerplate and error-prone; create a small helper function or component
(e.g., wrapWithFeatureBoundary or FeatureRouteWrapper) that accepts a report
component (NetWorth, Crossover, AgeOfMoney, CashFlow, CustomReport, Spending,
BudgetAnalysis, Summary, Calendar, Formula, Sankey) and returns the element
already wrapped by ErrorBoundary with FallbackComponent and resetKeys set to
[location.pathname], then replace each route element with a call to that helper
to remove duplication and keep behavior identical.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 4aaf8657-af7c-4ce9-bdf5-5fb2af671155

📥 Commits

Reviewing files that changed from the base of the PR and between dd3b114 and d32cf9f.

📒 Files selected for processing (2)
  • packages/desktop-client/src/components/reports/ReportRouter.tsx
  • upcoming-release-notes/7658.md

coderabbitai[bot]
coderabbitai Bot previously approved these changes Apr 29, 2026
@tmchow tmchow changed the title [WIP] feat(reports): scoped ErrorBoundaries for individual report routes feat(reports): scoped ErrorBoundaries for individual report routes Apr 29, 2026
@netlify

netlify Bot commented May 3, 2026 •

Copy link
Copy Markdown

✅ Deploy Preview for actualbudget-website ready!

Name Link
🔨 Latest commit cdd30e7
🔍 Latest deploy log https://app.netlify.com/projects/actualbudget-website/deploys/69f7fdde64de540008b9ef43
😎 Deploy Preview https://deploy-preview-7658.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.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🧹 Nitpick comments (1)
packages/desktop-client/src/components/reports/ReportRouter.tsx (1)

3-3: Consider creating or using a custom useLocation hook wrapper from src/hooks.

The coding guideline requires using custom hooks from src/hooks instead of consuming react-router hooks directly. useNavigate() already has a wrapper in the project following this pattern. For consistency, consider creating a useLocation wrapper hook or deferring this import until one exists.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@packages/desktop-client/src/components/reports/ReportRouter.tsx` at line 3,
ReportRouter currently imports useLocation directly from 'react-router'; per
project guidelines create a custom hook wrapper (e.g., export function
useLocation() { return useReactRouterLocation(); } or re-export) in your hooks
module and update ReportRouter to import useLocation from src/hooks instead of
'react-router' so it follows the established pattern used for useNavigate;
target the useLocation symbol and the ReportRouter component when applying the
change.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Nitpick comments:
In `@packages/desktop-client/src/components/reports/ReportRouter.tsx`:
- Line 3: ReportRouter currently imports useLocation directly from
'react-router'; per project guidelines create a custom hook wrapper (e.g.,
export function useLocation() { return useReactRouterLocation(); } or re-export)
in your hooks module and update ReportRouter to import useLocation from
src/hooks instead of 'react-router' so it follows the established pattern used
for useNavigate; target the useLocation symbol and the ReportRouter component
when applying the change.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 9970f8d0-7654-413f-9e24-5fbbdab92d80

📥 Commits

Reviewing files that changed from the base of the PR and between d32cf9f and 38bb4a5.

📒 Files selected for processing (1)
  • packages/desktop-client/src/components/reports/ReportRouter.tsx

coderabbitai[bot]
coderabbitai Bot previously approved these changes May 3, 2026
tmchow added 3 commits May 3, 2026 19:00
…7391)

Wrap each route in ReportRouter for NetWorth, CashFlow, Spending, etc.
in ErrorBoundary with FeatureErrorFallback. Matches the pattern used
for /rules routes in FinancesApp.tsx so a render error in a single
report no longer takes down the whole app.
…boilerplate

Each report route was wrapping its element in the same ErrorBoundary block
with FeatureErrorFallback and resetKeys={[location.pathname]}. Pull that
into a small withReportBoundary(element) helper inside ReportRouter so
each route is one line again.

Behavior is unchanged. The ErrorBoundary, FallbackComponent, and resetKeys
are identical to before; the helper just closes over location.pathname.

Addresses review feedback from @joel-jeremy and the CodeRabbit nitpick on
the same file (a custom Route component is not viable since react-router
v6's <Routes> requires literal <Route> children, but a helper function
gives the same boilerplate reduction).
@tmchow
tmchow force-pushed the osc/7391-error-boundaries-reports branch from 38bb4a5 to cdd30e7 Compare May 4, 2026 02:01
const budgetAnalysisReportEnabled = useFeatureFlag('budgetAnalysisReport');
const sankeyReportEnabled = useFeatureFlag('sankeyReport');

function withReportBoundary(element: ReactElement) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This should be defined outside of the ReportRouter function.

Move the per-route error-boundary helper out of ReportRouter as a
module-scoped component. ReportBoundary calls useLocation() internally so
each call site stays clean. Addresses review feedback.
@MatissJanis

Copy link
Copy Markdown
Member

@cursor resolve the merge conflicts in this pull request

Resolve ReportRouter.tsx conflict: keep ReportBoundary wrapping for all
report routes while adopting master's changes (crossover now always-on,
new balance-forecast routes behind balanceForecastReport flag).

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
@MatissJanis

Copy link
Copy Markdown
Member

@coderabbitai full review

@coderabbitai

coderabbitai Bot commented Jun 5, 2026 •

Copy link
Copy Markdown
Contributor
✅ Action performed

Full review finished.

@MatissJanis
MatissJanis enabled auto-merge June 5, 2026 20:56
@MatissJanis
MatissJanis added this pull request to the merge queue Jun 5, 2026
Merged via the queue into actualbudget:master with commit a8aa392 Jun 5, 2026
40 checks passed
mbreslow pushed a commit to mbreslow/actual that referenced this pull request Jun 8, 2026
…ctualbudget#7658)

* feat(reports): scoped ErrorBoundaries for individual report routes (actualbudget#7391)

Wrap each route in ReportRouter for NetWorth, CashFlow, Spending, etc.
in ErrorBoundary with FeatureErrorFallback. Matches the pattern used
for /rules routes in FinancesApp.tsx so a render error in a single
report no longer takes down the whole app.

* chore: rename release note to PR number

* refactor(reports): extract withReportBoundary helper to remove route boilerplate

Each report route was wrapping its element in the same ErrorBoundary block
with FeatureErrorFallback and resetKeys={[location.pathname]}. Pull that
into a small withReportBoundary(element) helper inside ReportRouter so
each route is one line again.

Behavior is unchanged. The ErrorBoundary, FallbackComponent, and resetKeys
are identical to before; the helper just closes over location.pathname.

Addresses review feedback from @joel-jeremy and the CodeRabbit nitpick on
the same file (a custom Route component is not viable since react-router
v6's <Routes> requires literal <Route> children, but a helper function
gives the same boilerplate reduction).

* refactor(reports): hoist withReportBoundary to ReportBoundary component

Move the per-route error-boundary helper out of ReportRouter as a
module-scoped component. ReportBoundary calls useLocation() internally so
each call site stays clean. Addresses review feedback.

---------

Co-authored-by: github-actions[bot] <[email protected]>
Co-authored-by: Claude Opus 4.8 (1M context) <[email protected]>
lelemm pushed a commit to lelemm/actual that referenced this pull request Jun 9, 2026
…ctualbudget#7658)

* feat(reports): scoped ErrorBoundaries for individual report routes (actualbudget#7391)

Wrap each route in ReportRouter for NetWorth, CashFlow, Spending, etc.
in ErrorBoundary with FeatureErrorFallback. Matches the pattern used
for /rules routes in FinancesApp.tsx so a render error in a single
report no longer takes down the whole app.

* chore: rename release note to PR number

* refactor(reports): extract withReportBoundary helper to remove route boilerplate

Each report route was wrapping its element in the same ErrorBoundary block
with FeatureErrorFallback and resetKeys={[location.pathname]}. Pull that
into a small withReportBoundary(element) helper inside ReportRouter so
each route is one line again.

Behavior is unchanged. The ErrorBoundary, FallbackComponent, and resetKeys
are identical to before; the helper just closes over location.pathname.

Addresses review feedback from @joel-jeremy and the CodeRabbit nitpick on
the same file (a custom Route component is not viable since react-router
v6's <Routes> requires literal <Route> children, but a helper function
gives the same boilerplate reduction).

* refactor(reports): hoist withReportBoundary to ReportBoundary component

Move the per-route error-boundary helper out of ReportRouter as a
module-scoped component. ReportBoundary calls useLocation() internally so
each call site stays clean. Addresses review feedback.

---------

Co-authored-by: github-actions[bot] <[email protected]>
Co-authored-by: Claude Opus 4.8 (1M context) <[email protected]>