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

Properly handle errors for SimpleFIN. #375

Merged
merged 4 commits into from
Jun 18, 2024

Conversation

psybers
Copy link
Contributor

@psybers psybers commented Jun 17, 2024

This PR tries to provide better error handling for SimpleFIN. First, sometimes the calls were never returning a response (they just return from the method) so this fixes that issues, which notifies the client side that something happened.

Second, it tries to provide better error messages on the client side.

@psybers psybers changed the title Properly handle errors for SimpleFIN. [WIP] Properly handle errors for SimpleFIN. Jun 17, 2024
@psybers psybers changed the title [WIP] Properly handle errors for SimpleFIN. Properly handle errors for SimpleFIN. Jun 17, 2024
@psybers
Copy link
Contributor Author

psybers commented Jun 17, 2024

Related actualbudget/actual#2891

Copy link
Member

@MatissJanis MatissJanis 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 your work on this! Just one small comment.

if (accessKey == null || accessKey === 'Forbidden') {
const token = secretsService.get(SecretName.simplefin_token);
if (token == null || token === 'Forbidden') {
throw new Error('No token');
Copy link
Member

Choose a reason for hiding this comment

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

💬 suggestion: ‏(comment applicable to all instances of thow within this file)

Would you mind either adding a prefix to the message OR creating a new Error class? If these errors happen - they will be printed in the error log. At which point it's easier to follow them if a bit more context is added.

Suggested change
throw new Error('No token');
throw new Error('SimpleFIN: no token provided');

Copy link
Contributor Author

@psybers psybers Jun 17, 2024

Choose a reason for hiding this comment

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

Even if they are caught? LIne 44 below catches these errors and actually re-throws a different error (with a better log message).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

(Or more accurately, it catches these and then returns an error response to the client and does not throw anything.)

Copy link
Member

Choose a reason for hiding this comment

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

Good comment. But this raises another point - could we have different error messages for each of the two different errors? The more granularity we have in error handling - the less support tickets we will get with confused users.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

In general, that is a good point. In this particular case though, if there is a problem with their access key or their setup token the solution is still the same: get a new setup token. So here I think a single error message makes most sense.

Copy link
Member

Choose a reason for hiding this comment

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

Good point 👍

@MatissJanis MatissJanis merged commit 73d0f04 into actualbudget:master Jun 18, 2024
6 checks passed
Copy link

@iffy iffy left a comment

Choose a reason for hiding this comment

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

I know this is already merged -- someone just pointed me to it, and I thought I'd add some helpful comments.

const account = results.accounts.find((a) => a.id === accountId);

const needsAttention = results.errors.find(
(e) => e === `Connection to ${account.org.name} may need attention`,
Copy link

Choose a reason for hiding this comment

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

Someone pointed me to this PR that now surfaces errors to users. This is great! Seeing this string matching, though, makes me think that SimpleFIN ought to return published error codes in addition to error messages. I'll try to make that happen soon.

Copy link
Member

@MatissJanis MatissJanis Jul 3, 2024

Choose a reason for hiding this comment

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

Great! Could you update us when/if you implement this in Simplefin? <3

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Someone pointed me to this PR that now surfaces errors to users. This is great! Seeing this string matching, though, makes me think that SimpleFIN ought to return published error codes in addition to error messages. I'll try to make that happen soon.

@iffy Thanks! Honestly what would be the most helpful is if the errors were contextualized to the account data itself. So then you would know which error matches which specific account(s).

Copy link

Choose a reason for hiding this comment

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

That's a good idea. I'll ping you when it happens.

src/app-simplefin/app-simplefin.js Show resolved Hide resolved
MMichotte pushed a commit to MMichotte/actual-server that referenced this pull request Sep 9, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants