Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix error spread in non-batch bank sync #4689

Merged

Conversation

mariolamacchia
Copy link
Contributor

Fixed an issue in the bank sync API where errors weren't being properly collected during bank sync, which led to non-batch syncs to always fail.

@actual-github-bot actual-github-bot bot changed the title Fix error spread bank sync [WIP] Fix error spread bank sync Mar 25, 2025
@mariolamacchia mariolamacchia changed the title [WIP] Fix error spread bank sync Fix error spread in non-batch bank sync Mar 25, 2025
Copy link

netlify bot commented Mar 25, 2025

Deploy Preview for actualbudget ready!

Name Link
🔨 Latest commit 28efe5f
🔍 Latest deploy log https://app.netlify.com/sites/actualbudget/deploys/67e3bfe3cf29db0008a370f8
😎 Deploy Preview https://deploy-preview-4689.demo.actualbudget.org
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

Copy link
Contributor

github-actions bot commented Mar 25, 2025

Bundle Stats — desktop-client

Hey there, this message comes from a GitHub action that helps you and reviewers to understand how these changes affect the size of this project's bundle.

As this PR is updated, I'll keep you updated on how the bundle size is impacted.

Total

Files count Total bundle size % Changed
18 8.5 MB → 8.5 MB (-101 B) -0.00%
Changeset
File Δ Size
node_modules/clsx/dist/clsx.mjs 🆕 +368 B 0 B → 368 B
node_modules/clsx/dist/clsx.mjs?commonjs-proxy 🆕 +64 B 0 B → 64 B
node_modules/react-grid-layout/build/components/WidthProvider.js 📈 +1 B (+0.02%) 5.22 kB → 5.22 kB
node_modules/react-grid-layout/build/GridItem.js 📈 +1 B (+0.00%) 21.49 kB → 21.49 kB
node_modules/react-grid-layout/build/ReactGridLayout.js 📈 +1 B (+0.00%) 24.96 kB → 24.96 kB
node_modules/clsx/dist/clsx.js 🔥 -509 B (-100%) 509 B → 0 B
node_modules/clsx/dist/clsx.js?commonjs-module 🔥 -27 B (-100%) 27 B → 0 B
View detailed bundle breakdown

Added

No assets were added

Removed

No assets were removed

Bigger

Asset File Size % Changed
static/js/ReportRouter.js 1.59 MB → 1.59 MB (+67 B) +0.00%

Smaller

Asset File Size % Changed
static/js/index.js 5.5 MB → 5.5 MB (-168 B) -0.00%

Unchanged

Asset File Size % Changed
static/js/en-GB.js 5.37 kB 0%
static/js/de.js 121.27 kB 0%
static/js/nl.js 102.79 kB 0%
static/js/resize-observer.js 18.37 kB 0%
static/js/indexeddb-main-thread-worker-e59fee74.js 13.5 kB 0%
static/js/fr.js 128.02 kB 0%
static/js/workbox-window.prod.es5.js 5.69 kB 0%
static/js/en.js 110.12 kB 0%
static/js/uk.js 110.59 kB 0%
static/js/pt-BR.js 120.98 kB 0%
static/js/es.js 65.71 kB 0%
static/js/BackgroundImage.js 122.29 kB 0%
static/js/narrow.js 383.22 kB 0%
static/js/useAccountPreviewTransactions.js 1.69 kB 0%
static/js/AppliedFilters.js 10.87 kB 0%
static/js/wide.js 112.23 kB 0%

Copy link
Contributor

github-actions bot commented Mar 25, 2025

Bundle Stats — loot-core

Hey there, this message comes from a GitHub action that helps you and reviewers to understand how these changes affect the size of this project's bundle.

As this PR is updated, I'll keep you updated on how the bundle size is impacted.

Total

Files count Total bundle size % Changed
1 2.28 MB → 2.28 MB (+3 B) +0.00%
Changeset
File Δ Size
packages/loot-core/src/server/api.ts 📈 +3 B (+0.01%) 21.27 kB → 21.27 kB
View detailed bundle breakdown

Added

No assets were added

Removed

No assets were removed

Bigger

Asset File Size % Changed
kcab.worker.js 2.28 MB → 2.28 MB (+3 B) +0.00%

Smaller

No assets were smaller

Unchanged

No assets were unchanged

Copy link
Contributor

coderabbitai bot commented Mar 25, 2025

Walkthrough

This pull request introduces a new test file api.test.ts for validating the API handlers related to bank synchronization. The tests, written with Jest, include a setup phase that defines mock server handlers and ensures existing handlers are replaced. The test suite contains two tests: one verifies that the accounts-bank-sync handler is called with the correct parameters when an accountId is provided, and the other checks that errors during non-batch synchronization are handled correctly, ensuring that the getBankSyncError function is invoked with the appropriate error code. Additionally, the error aggregation in the handlers['api/bank-sync'] function has been modified to flatten the errors array using the spread operator, allowing multiple error messages to be added individually. No changes were made to the declarations of exported or public entities.

Suggested labels

:sparkles: Merged

Suggested reviewers

  • youngcw
  • matt-fidd

📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between fd248e4 and 28efe5f.

📒 Files selected for processing (1)
  • packages/loot-core/src/server/api.test.ts (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • packages/loot-core/src/server/api.test.ts
⏰ Context from checks skipped due to timeout of 90000ms (4)
  • GitHub Check: Functional
  • GitHub Check: Visual regression
  • GitHub Check: build (ubuntu-latest)
  • GitHub Check: build (windows-latest)

🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai plan to trigger planning for file edits and PR creation.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 3

🧹 Nitpick comments (2)
packages/loot-core/src/server/api.test.ts (2)

1-6: Reorder imports to match project conventions

According to the linter, the imports need to be reordered and grouped properly.

-import { installAPI } from './api';
-import { getBankSyncError } from '../shared/errors';
+import { getBankSyncError } from '../shared/errors';
+
+import { installAPI } from './api';
🧰 Tools
🪛 GitHub Check: lint

[warning] 2-2:
../shared/errors import should occur before import of ./api


[warning] 1-1:
There should be at least one empty line between import groups


21-23: Avoid using the delete operator for performance reasons

The static analysis tool warns against using the delete operator due to potential performance impacts.

-      delete handlers['accounts-bank-sync'];
+      handlers['accounts-bank-sync'] = undefined;
🧰 Tools
🪛 Biome (1.9.4)

[error] 22-22: Avoid the delete operator which can impact performance.

Unsafe fix: Use an undefined assignment instead.

(lint/performance/noDelete)

🪛 GitHub Check: typecheck

[failure] 21-21:
Variable 'handlers' implicitly has an 'any' type.

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 161c062 and 56f6abd.

⛔ Files ignored due to path filters (1)
  • upcoming-release-notes/4689.md is excluded by !**/*.md
📒 Files selected for processing (2)
  • packages/loot-core/src/server/api.test.ts (1 hunks)
  • packages/loot-core/src/server/api.ts (1 hunks)
🧰 Additional context used
🧬 Code Definitions (1)
packages/loot-core/src/server/api.test.ts (1)
packages/loot-core/src/server/api.ts (1)
  • installAPI (769-773)
🪛 Biome (1.9.4)
packages/loot-core/src/server/api.test.ts

[error] 22-22: Avoid the delete operator which can impact performance.

Unsafe fix: Use an undefined assignment instead.

(lint/performance/noDelete)

🪛 GitHub Check: lint
packages/loot-core/src/server/api.test.ts

[warning] 2-2:
../shared/errors import should occur before import of ./api


[warning] 1-1:
There should be at least one empty line between import groups

🪛 GitHub Check: typecheck
packages/loot-core/src/server/api.test.ts

[failure] 42-42:
Variable 'handlers' implicitly has an 'any' type.


[failure] 37-37:
Variable 'mockServerHandlers' implicitly has an 'any' type.


[failure] 31-31:
Variable 'mockServerHandlers' implicitly has an 'any' type.


[failure] 30-30:
Variable 'handlers' implicitly has an 'any' type.


[failure] 21-21:
Variable 'handlers' implicitly has an 'any' type.


[failure] 16-16:
Object literal may only specify known properties, and ''accounts-bank-sync'' does not exist in type 'ServerHandlers'.


[failure] 10-10:
Variable 'mockServerHandlers' implicitly has type 'any' in some locations where its type cannot be determined.


[failure] 9-9:
Variable 'handlers' implicitly has type 'any' in some locations where its type cannot be determined.

🪛 GitHub Actions: Test
packages/loot-core/src/server/api.test.ts

[error] 9-9: error TS7034: Variable 'handlers' implicitly has type 'any' in some locations where its type cannot be determined.

⏰ Context from checks skipped due to timeout of 90000ms (4)
  • GitHub Check: Functional
  • GitHub Check: Visual regression
  • GitHub Check: build (ubuntu-latest)
  • GitHub Check: build (windows-latest)
🔇 Additional comments (3)
packages/loot-core/src/server/api.ts (1)

261-261: Fixed error collection in non-batch bank sync

The change from allErrors.push(errors) to allErrors.push(...errors) correctly flattens the errors array rather than nesting it. This ensures that errors from non-batch syncs are properly aggregated and can be detected in the subsequent error filtering and handling.

packages/loot-core/src/server/api.test.ts (2)

28-35: Test for single account sync - LGTM

This is a well-structured test that verifies the api/bank-sync handler correctly passes the account ID to the underlying accounts-bank-sync handler when in non-batch mode.

🧰 Tools
🪛 GitHub Check: typecheck

[failure] 31-31:
Variable 'mockServerHandlers' implicitly has an 'any' type.


[failure] 30-30:
Variable 'handlers' implicitly has an 'any' type.


36-47: Test for error handling in non-batch sync - LGTM

Good test that verifies error handling in non-batch sync mode. It ensures that errors from the accounts-bank-sync handler are properly thrown and formatted using getBankSyncError.

🧰 Tools
🪛 GitHub Check: typecheck

[failure] 42-42:
Variable 'handlers' implicitly has an 'any' type.


[failure] 37-37:
Variable 'mockServerHandlers' implicitly has an 'any' type.

Comment on lines 8 to 48
describe('API handlers', () => {
let handlers;
let mockServerHandlers;

beforeEach(() => {
jest.clearAllMocks();

mockServerHandlers = {
'accounts-bank-sync': jest.fn().mockResolvedValue({ errors: [] }),
};

// Remove the accounts-bank-sync handler if it exists
// or it won't be replaced by the mock
if (handlers) {
delete handlers['accounts-bank-sync'];
}

handlers = installAPI(mockServerHandlers);
});

describe('api/bank-sync', () => {
it('should sync a single account when accountId is provided', async () => {
await handlers['api/bank-sync']({ accountId: 'account1' });
expect(mockServerHandlers['accounts-bank-sync']).toHaveBeenCalledWith({
ids: ['account1'],
});
});

it('should handle errors in non batch sync', async () => {
mockServerHandlers['accounts-bank-sync'].mockResolvedValue({
errors: ['connection-failed'],
});

await expect(
handlers['api/bank-sync']({ accountId: 'account2' }),
).rejects.toThrow('Bank sync error: connection-failed');

expect(getBankSyncError).toHaveBeenCalledWith('connection-failed');
});
});
});
Copy link
Contributor

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

Add TypeScript type imports to test file

To address the TypeScript errors throughout the file, add the necessary type imports from server-handlers.

 import { installAPI } from './api';
 import { getBankSyncError } from '../shared/errors';
+import { Handlers } from '../types/handlers';
+import { ServerHandlers } from '../types/server-handlers';
 
 jest.mock('../shared/errors', () => ({
   getBankSyncError: jest.fn(error => `Bank sync error: ${error}`),
 }));
 
 describe('API handlers', () => {
-  let handlers;
-  let mockServerHandlers;
+  let handlers: Handlers;
+  let mockServerHandlers: Partial<ServerHandlers>;

This will properly address the TypeScript errors throughout the file and make the code more maintainable.

📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
describe('API handlers', () => {
let handlers;
let mockServerHandlers;
beforeEach(() => {
jest.clearAllMocks();
mockServerHandlers = {
'accounts-bank-sync': jest.fn().mockResolvedValue({ errors: [] }),
};
// Remove the accounts-bank-sync handler if it exists
// or it won't be replaced by the mock
if (handlers) {
delete handlers['accounts-bank-sync'];
}
handlers = installAPI(mockServerHandlers);
});
describe('api/bank-sync', () => {
it('should sync a single account when accountId is provided', async () => {
await handlers['api/bank-sync']({ accountId: 'account1' });
expect(mockServerHandlers['accounts-bank-sync']).toHaveBeenCalledWith({
ids: ['account1'],
});
});
it('should handle errors in non batch sync', async () => {
mockServerHandlers['accounts-bank-sync'].mockResolvedValue({
errors: ['connection-failed'],
});
await expect(
handlers['api/bank-sync']({ accountId: 'account2' }),
).rejects.toThrow('Bank sync error: connection-failed');
expect(getBankSyncError).toHaveBeenCalledWith('connection-failed');
});
});
});
import { installAPI } from './api';
import { getBankSyncError } from '../shared/errors';
import { Handlers } from '../types/handlers';
import { ServerHandlers } from '../types/server-handlers';
jest.mock('../shared/errors', () => ({
getBankSyncError: jest.fn(error => `Bank sync error: ${error}`),
}));
describe('API handlers', () => {
let handlers: Handlers;
let mockServerHandlers: Partial<ServerHandlers>;
beforeEach(() => {
jest.clearAllMocks();
mockServerHandlers = {
'accounts-bank-sync': jest.fn().mockResolvedValue({ errors: [] }),
};
// Remove the accounts-bank-sync handler if it exists
// or it won't be replaced by the mock
if (handlers) {
delete handlers['accounts-bank-sync'];
}
handlers = installAPI(mockServerHandlers);
});
describe('api/bank-sync', () => {
it('should sync a single account when accountId is provided', async () => {
await handlers['api/bank-sync']({ accountId: 'account1' });
expect(mockServerHandlers['accounts-bank-sync']).toHaveBeenCalledWith({
ids: ['account1'],
});
});
it('should handle errors in non batch sync', async () => {
mockServerHandlers['accounts-bank-sync'].mockResolvedValue({
errors: ['connection-failed'],
});
await expect(
handlers['api/bank-sync']({ accountId: 'account2' }),
).rejects.toThrow('Bank sync error: connection-failed');
expect(getBankSyncError).toHaveBeenCalledWith('connection-failed');
});
});
});
🧰 Tools
🪛 Biome (1.9.4)

[error] 22-22: Avoid the delete operator which can impact performance.

Unsafe fix: Use an undefined assignment instead.

(lint/performance/noDelete)

🪛 GitHub Check: typecheck

[failure] 42-42:
Variable 'handlers' implicitly has an 'any' type.


[failure] 37-37:
Variable 'mockServerHandlers' implicitly has an 'any' type.


[failure] 31-31:
Variable 'mockServerHandlers' implicitly has an 'any' type.


[failure] 30-30:
Variable 'handlers' implicitly has an 'any' type.


[failure] 21-21:
Variable 'handlers' implicitly has an 'any' type.


[failure] 16-16:
Object literal may only specify known properties, and ''accounts-bank-sync'' does not exist in type 'ServerHandlers'.


[failure] 10-10:
Variable 'mockServerHandlers' implicitly has type 'any' in some locations where its type cannot be determined.


[failure] 9-9:
Variable 'handlers' implicitly has type 'any' in some locations where its type cannot be determined.

🪛 GitHub Actions: Test

[error] 9-9: error TS7034: Variable 'handlers' implicitly has type 'any' in some locations where its type cannot be determined.

@matt-fidd
Copy link
Contributor

Hey! This would be nice to get in before the release in a couple of days if possible, could you take a look at the failing CI when you get a chance?

@matt-fidd matt-fidd self-assigned this Mar 26, 2025
@matt-fidd matt-fidd added this to the v25.4.0 milestone Mar 26, 2025
mariolamacchia and others added 2 commits March 26, 2025 08:28
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
…udget#4683)

fix issue where filters set in the widget editor for the cash flow widget were not applied in the Reports dashboard
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

♻️ Duplicate comments (2)
packages/loot-core/src/server/api.test.ts (2)

1-10: ⚠️ Potential issue

Fix TypeScript type errors by importing proper types.

The current type definitions are causing pipeline failures because Record<string, jest.Mock> is not assignable to the ServerHandlers type expected by installAPI. Fix this by importing the correct types.

+import { Handlers } from '../types/handlers';
+import { ServerHandlers } from '../types/server-handlers';
 import { installAPI } from './api';
 import { getBankSyncError } from '../shared/errors';

 jest.mock('../shared/errors', () => ({
   getBankSyncError: jest.fn(error => `Bank sync error: ${error}`),
 }));

 describe('API handlers', () => {
-  let handlers: Record<string, any>;
-  let mockServerHandlers: Record<string, jest.Mock>;
+  let handlers: Handlers;
+  let mockServerHandlers: Partial<ServerHandlers>;
🧰 Tools
🪛 ESLint

[error] 9-9: Unexpected any. Specify a different type.

(@typescript-eslint/no-explicit-any)

🪛 GitHub Check: lint

[failure] 9-9:
Unexpected any. Specify a different type


[warning] 2-2:
../shared/errors import should occur before import of ./api


[warning] 1-1:
There should be at least one empty line between import groups


15-17: ⚠️ Potential issue

Fix type assertion for mockServerHandlers.

The current object literal doesn't match the ServerHandlers type expected by installAPI. Correct it with a proper type assertion.

 mockServerHandlers = {
   'accounts-bank-sync': jest.fn().mockResolvedValue({ errors: [] }),
-};
+} as Partial<ServerHandlers>;
🧹 Nitpick comments (2)
packages/loot-core/src/server/api.test.ts (2)

1-3: Fix import ordering to follow project's conventions.

The imports should be organized alphabetically with external imports coming before local imports.

+import { getBankSyncError } from '../shared/errors';
 import { installAPI } from './api';
-import { getBankSyncError } from '../shared/errors';
🧰 Tools
🪛 GitHub Check: lint

[warning] 2-2:
../shared/errors import should occur before import of ./api


[warning] 1-1:
There should be at least one empty line between import groups


21-23: Replace delete operator with undefined assignment for better performance.

Using the delete operator can impact performance. Use undefined assignment instead.

 if (handlers) {
-  delete handlers['accounts-bank-sync'];
+  handlers['accounts-bank-sync'] = undefined;
 }
🧰 Tools
🪛 Biome (1.9.4)

[error] 22-22: Avoid the delete operator which can impact performance.

Unsafe fix: Use an undefined assignment instead.

(lint/performance/noDelete)

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 56f6abd and 4e69057.

📒 Files selected for processing (1)
  • packages/loot-core/src/server/api.test.ts (1 hunks)
🧰 Additional context used
🧬 Code Definitions (1)
packages/loot-core/src/server/api.test.ts (1)
packages/loot-core/src/server/api.ts (1)
  • installAPI (769-773)
🪛 Biome (1.9.4)
packages/loot-core/src/server/api.test.ts

[error] 22-22: Avoid the delete operator which can impact performance.

Unsafe fix: Use an undefined assignment instead.

(lint/performance/noDelete)

🪛 ESLint
packages/loot-core/src/server/api.test.ts

[error] 9-9: Unexpected any. Specify a different type.

(@typescript-eslint/no-explicit-any)

🪛 GitHub Check: typecheck
packages/loot-core/src/server/api.test.ts

[failure] 25-25:
Argument of type 'Record<string, Mock<any, any, any>>' is not assignable to parameter of type 'ServerHandlers'.

🪛 GitHub Check: lint
packages/loot-core/src/server/api.test.ts

[failure] 9-9:
Unexpected any. Specify a different type


[warning] 2-2:
../shared/errors import should occur before import of ./api


[warning] 1-1:
There should be at least one empty line between import groups

🪛 GitHub Actions: Test
packages/loot-core/src/server/api.test.ts

[error] 25-27: error TS2345: Argument of type 'Record<string, Mock<any, any, any>>' is not assignable to parameter of type 'ServerHandlers'.

🪛 GitHub Actions: Build
packages/loot-core/src/server/api.test.ts

[error] 25-27: Argument of type 'Record<string, Mock<any, any, any>>' is not assignable to parameter of type 'ServerHandlers'.

⏰ Context from checks skipped due to timeout of 90000ms (4)
  • GitHub Check: Visual regression
  • GitHub Check: Functional
  • GitHub Check: build (ubuntu-latest)
  • GitHub Check: build (windows-latest)
🔇 Additional comments (2)
packages/loot-core/src/server/api.test.ts (2)

29-34: LGTM: Test correctly validates single account sync behavior.

The test properly verifies that when an accountId is provided, the 'accounts-bank-sync' handler is called with the correct parameters.


36-46: LGTM: Test properly validates error handling in non-batch sync.

This test correctly verifies that:

  1. Errors from 'accounts-bank-sync' are properly thrown
  2. The getBankSyncError function is called with the correct error code

This directly addresses the PR's objective of fixing error handling in non-batch bank sync.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 4e69057 and fd248e4.

📒 Files selected for processing (1)
  • packages/loot-core/src/server/api.test.ts (1 hunks)
🧰 Additional context used
🪛 GitHub Check: lint
packages/loot-core/src/server/api.test.ts

[warning] 1-1:
./api import should occur after import of ../types/server-handlers


[warning] 1-1:
There should be at least one empty line between import groups

🪛 GitHub Actions: Test
packages/loot-core/src/server/api.test.ts

[warning] 1-1: There should be at least one empty line between import groups (import/order)


[warning] 1-1: ./api import should occur after import of ../types/server-handlers (import/order)

⏰ Context from checks skipped due to timeout of 90000ms (4)
  • GitHub Check: Functional
  • GitHub Check: Visual regression
  • GitHub Check: build (windows-latest)
  • GitHub Check: build (ubuntu-latest)
🔇 Additional comments (3)
packages/loot-core/src/server/api.test.ts (3)

9-11: LGTM - Good job adding proper type annotations.

The type assertion for ServerHandlers properly resolves the TypeScript errors mentioned in previous reviews.


12-22: Good test for single account sync functionality.

This test correctly verifies that when an accountId is provided, the 'accounts-bank-sync' handler is called with the appropriate parameters.


24-35: Well-implemented error handling test.

This test effectively validates the key issue from the PR objectives - ensuring that errors are properly captured during non-batch bank sync operations. The test verifies both the thrown error and that the error formatting function is called correctly.

Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
@mariolamacchia
Copy link
Contributor Author

@matt-fidd fixed! Thanks for taking a look

Copy link
Contributor

@matt-fidd matt-fidd left a comment

Choose a reason for hiding this comment

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

Thanks for this!

@matt-fidd matt-fidd merged commit 31ed128 into actualbudget:master Mar 26, 2025
21 checks passed
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.

3 participants