-
-
Notifications
You must be signed in to change notification settings - Fork 660
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
use SimpleFin pending flag for cleared status #494
Conversation
WalkthroughThe pull request introduces modifications to the Possibly related PRs
Suggested labels
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? 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
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)
Other keywords and placeholders
CodeRabbit Configuration File (
|
@psybers I'd appreciate your eyes on this just to check it works reliably across providers |
There was a problem hiding this 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
🧹 Outside diff range and nitpick comments (2)
src/app-simplefin/app-simplefin.js (2)
Line range hint
82-91
: Improve error handling and remove debug logging.While the validation logic is correct, there are a few improvements that could be made:
- The
console.log
statements should not be in production code- Error messages could be more descriptive by including the actual types received
Consider this improved implementation:
if (Array.isArray(accountId) != Array.isArray(startDate)) { - console.log(accountId, startDate); throw new Error( - 'accountId and startDate must either both be arrays or both be strings', + `Type mismatch: accountId is ${Array.isArray(accountId) ? 'array' : typeof accountId} while startDate is ${Array.isArray(startDate) ? 'array' : typeof startDate}. Both must be of the same type.` ); } if (Array.isArray(accountId) && accountId.length !== startDate.length) { - console.log(accountId, startDate); throw new Error( - 'accountId and startDate arrays must be the same length' + `Length mismatch: accountId has ${accountId.length} elements while startDate has ${startDate.length} elements` ); }
Line range hint
1-450
: Consider implementing a consistent error handling strategy.The current implementation mixes different error handling approaches:
- Some errors are handled via utility functions (
invalidToken
,serverDown
)- Others are thrown directly and caught by
handleError
middleware- Some errors are accumulated in the
results.errors
objectConsider implementing a consistent error handling strategy:
- Define an error type hierarchy for different error cases
- Centralize error response formatting
- Use consistent error handling patterns across all routes
Example approach:
// Define error types class SimplefinError extends Error { constructor(type, code, reason) { super(reason); this.error_type = type; this.error_code = code; } } class InvalidTokenError extends SimplefinError { constructor() { super('INVALID_ACCESS_TOKEN', 'INVALID_ACCESS_TOKEN', 'Invalid SimpleFIN access token. Reset the token and re-link any broken accounts.'); } } // Centralized error handler function handleSimplefinError(error, res) { res.send({ status: 'ok', data: { error_type: error.error_type, error_code: error.error_code, status: 'rejected', reason: error.message } }); }Would you like me to create a GitHub issue to track this architectural improvement?
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
⛔ Files ignored due to path filters (1)
upcoming-release-notes/494.md
is excluded by!**/*.md
📒 Files selected for processing (1)
src/app-simplefin/app-simplefin.js
(1 hunks)
@matt-fidd I can say that with my banks, |
Looking at the SimpleFin docs,
posted === 0
is not always a reliable indicator of transaction cleared status. We should prefer the pending flag if present.