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

Misc Cleanup #4455

Open
wants to merge 9 commits into
base: master
Choose a base branch
from
Open

Misc Cleanup #4455

wants to merge 9 commits into from

Conversation

rugulous
Copy link

This PR addresses miscellaneous little nitpicks and fixes 2 bugs

  • The repo previously didn't run on Windows - although the rest of the bash scripts worked fine, the find command to build the index of data files was defaulting to find.exe instead of /usr/bin/find. This meant that it built and spun up, but then I was plagued by errors because the default file system wasn't being created properly!

  • secret-check always failed - the headers weren't being set correctly and so the token wasn't being passed. This PR fixes that issue, although I'm not sure it's actually used anywhere in the main codebase

The rest of the code is mostly just removing duplications and making things easier to read. There's one area of contention I can forsee though - I've updated throwIfNot200 to effectively function as throwIfNot2xx, but I wasn't sure if this is the behaviour that's desired or if we want to just use response.ok, or if it is correct to only be 200 codes

@actual-github-bot actual-github-bot bot changed the title Misc Cleanup [WIP] Misc Cleanup Feb 26, 2025
Copy link

netlify bot commented Feb 26, 2025

Deploy Preview for actualbudget ready!

Name Link
🔨 Latest commit 06f35b1
🔍 Latest deploy log https://app.netlify.com/sites/actualbudget/deploys/67beff4649eaa3000878d1f2
😎 Deploy Preview https://deploy-preview-4455.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 Feb 26, 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
17 7.01 MB → 7.01 MB (+3.36 kB) +0.05%
Changeset
File Δ Size
locale/fr.json 📈 +3.57 kB (+4.15%) 85.85 kB → 89.42 kB
src/components/modals/CreateAccountModal.tsx 📉 -90 B (-0.55%) 16.03 kB → 15.94 kB
src/components/modals/SelectLinkedAccountsModal.jsx 📉 -117 B (-1.43%) 8.02 kB → 7.9 kB
View detailed bundle breakdown

Added

No assets were added

Removed

No assets were removed

Bigger

Asset File Size % Changed
static/js/fr.js 85.85 kB → 89.42 kB (+3.57 kB) +4.15%

Smaller

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

Unchanged

Asset File Size % Changed
static/js/en-GB.js 99.33 kB 0%
static/js/de.js 115.06 kB 0%
static/js/en.js 103.19 kB 0%
static/js/nl.js 98.45 kB 0%
static/js/pt-BR.js 113.53 kB 0%
static/js/uk.js 111.11 kB 0%
static/js/indexeddb-main-thread-worker-e59fee74.js 13.5 kB 0%
static/js/workbox-window.prod.es5.js 5.69 kB 0%
static/js/resize-observer.js 18.37 kB 0%
static/js/BackgroundImage.js 122.29 kB 0%
static/js/useAccountPreviewTransactions.js 1.69 kB 0%
static/js/AppliedFilters.js 10.79 kB 0%
static/js/narrow.js 86.21 kB 0%
static/js/wide.js 102.9 kB 0%
static/js/ReportRouter.js 1.59 MB 0%

Copy link
Contributor

github-actions bot commented Feb 26, 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 1.34 MB → 1.34 MB (+13 B) +0.00%
Changeset
File Δ Size
packages/loot-core/src/server/post.ts 📈 +81 B (+1.45%) 5.46 kB → 5.54 kB
packages/loot-core/src/server/accounts/app.ts 📈 +41 B (+0.17%) 23.33 kB → 23.37 kB
View detailed bundle breakdown

Added

No assets were added

Removed

No assets were removed

Bigger

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

Smaller

No assets were smaller

Unchanged

No assets were unchanged

@rugulous rugulous changed the title [WIP] Misc Cleanup Misc Cleanup Feb 26, 2025
Copy link
Contributor

coderabbitai bot commented Feb 26, 2025

Walkthrough

The changes span multiple components across the project. In the desktop client, the CreateAccountModal simplifies the onConnectGoCardless function by removing redundant conditional checks, while the SelectLinkedAccountsModal refactors the assignment of upgradingId for improved readability. In the loot-core package, build scripts in both the API and browser modules now specify the full path (/usr/bin/find) for locating files, ensuring consistency across environments. On the server side, the checkSecret function in the accounts module has been reorganized to wrap headers in a dedicated object. Additionally, the error handling logic in the throwIfNot200 function has been updated to accept a broader range of successful (2xx) responses and to simplify error messaging for specific HTTP statuses. None of these modifications alter the exported or public entities.

Possibly related PRs

Suggested labels

:sparkles: Merged

Suggested reviewers

  • matt-fidd
  • jfdoming

Tip

CodeRabbit's docstrings feature is now available as part of our Pro Plan! Simply use the command @coderabbitai generate docstrings to have CodeRabbit automatically generate docstrings for your pull request. We would love to hear your feedback on Discord.

✨ Finishing Touches
  • 📝 Generate Docstrings

Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

❤️ Share
🪧 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 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: 0

🧹 Nitpick comments (1)
packages/loot-core/src/server/post.ts (1)

18-22: Consider adding error boundary for JSON parsing.

While the JSON parsing logic is correct, consider wrapping it in a try-catch block to handle malformed JSON responses gracefully.

 const contentType = res.headers.get('Content-Type') ?? '';
 if (contentType.toLowerCase().indexOf('application/json') !== -1) {
+  try {
     const json = JSON.parse(text);
     throw new PostError(json.reason);
+  } catch (err) {
+    throw new PostError('invalid-json-response');
+  }
 }
📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 5214549 and b9bb328.

⛔ Files ignored due to path filters (1)
  • upcoming-release-notes/4455.md is excluded by !**/*.md
📒 Files selected for processing (6)
  • packages/desktop-client/src/components/modals/CreateAccountModal.tsx (1 hunks)
  • packages/desktop-client/src/components/modals/SelectLinkedAccountsModal.jsx (2 hunks)
  • packages/loot-core/bin/build-api (1 hunks)
  • packages/loot-core/bin/build-browser (1 hunks)
  • packages/loot-core/src/server/accounts/app.ts (1 hunks)
  • packages/loot-core/src/server/post.ts (1 hunks)
✅ Files skipped from review due to trivial changes (3)
  • packages/loot-core/bin/build-api
  • packages/loot-core/src/server/accounts/app.ts
  • packages/loot-core/bin/build-browser
🧰 Additional context used
🧠 Learnings (1)
packages/desktop-client/src/components/modals/SelectLinkedAccountsModal.jsx (1)
Learnt from: dkhalife
PR: actualbudget/actual#3984
File: packages/desktop-client/src/components/modals/SelectLinkedAccountsModal.tsx:43-68
Timestamp: 2025-01-03T03:27:48.005Z
Learning: We have 2 types for accounts: `NormalizedAccount` (bank account ID field is `id`) and `AccountEntity` (database ID field is `id` plus a `account_id` that stores the bank’s ID). Accordingly, `account_id` shouldn't be replaced by `id` in `AccountEntity`.
⏰ Context from checks skipped due to timeout of 90000ms (2)
  • GitHub Check: Visual regression
  • GitHub Check: build (ubuntu-latest)
🔇 Additional comments (6)
packages/loot-core/src/server/post.ts (3)

8-12: LGTM! Improved HTTP status code handling.

The change to accept all 2xx status codes as success is a good improvement, aligning with HTTP standards where all 2xx codes indicate successful responses.


14-16: Simplify error handling for 500 status.

The simplified error handling for 500 status is cleaner and more maintainable.


24-34: LGTM! Well-documented tunnel error handling.

The tunnel error detection is well-implemented and clearly documented.

packages/desktop-client/src/components/modals/CreateAccountModal.tsx (1)

54-54: LGTM! Simplified function logic.

The direct call to authorizeBank(dispatch) removes unnecessary conditional branching, making the code cleaner and more maintainable.

packages/desktop-client/src/components/modals/SelectLinkedAccountsModal.jsx (2)

81-85: LGTM! Improved code readability.

The extracted upgradingId assignment logic improves readability while correctly handling account IDs. The implementation aligns with the established pattern of distinguishing between bank account IDs and database IDs.


92-93: LGTM! Consistent usage of upgradingId.

The consistent usage of the extracted upgradingId in both linkAccountSimpleFin and linkAccount calls maintains code clarity.

Also applies to: 101-102

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.

1 participant