🥅 server: bridge credential fallback and retry on timeout#896
🥅 server: bridge credential fallback and retry on timeout#896cruzdanilo merged 2 commits intomainfrom
Conversation
🦋 Changeset detectedLatest commit: 504c9b6 The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
|
Note Reviews pausedIt 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 Use the following commands to manage reviews:
Use the checkboxes below for quick actions:
WalkthroughAdds persona email-based credential fallback for bridge webhook handling, idempotent Ramp customer creation with retry-on-timeout/5xx, a Persona accounts search helper, a unique constraint on Changes
Sequence DiagramsequenceDiagram
participant Client as Client/API
participant Hook as Bridge Hook
participant DB as Database
participant Persona as Persona API
participant Sentry as Sentry/Events
Client->>Hook: webhook customer.updated.status_transitioned
Hook->>DB: lookup credential by account/bridgeId
alt credential found
Hook-->>Client: proceed with credential
else credential missing
Hook->>Hook: getCustomer(bridgeId)
alt customer found
Hook->>Persona: searchAccounts(customer.email)
Persona-->>Hook: accounts list
alt single match (reference-id)
Hook->>DB: update credentials where id==reference-id set bridgeId
DB-->>Hook: update success / constraint error
alt update success
Hook->>Sentry: captureEvent("bridge credential paired")
Hook-->>Client: return updated credential
else unique constraint (already paired)
Hook->>Sentry: captureEvent("bridge credential already paired")
Hook-->>Client: credential not found
end
else multiple matches
Hook->>Sentry: captureException(multiple matches)
Hook-->>Client: credential not found
else no matches
Hook->>Sentry: captureException(credential not found)
Hook-->>Client: credential not found
end
else customer missing
Hook->>Sentry: captureException(credential not found)
Hook-->>Client: credential not found
end
end
Estimated code review effort🎯 4 (Complex) | ⏱️ ~45 minutes Possibly related PRs
Suggested reviewers
🚥 Pre-merge checks | ✅ 2✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
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. Comment |
Summary of ChangesHello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request significantly improves the robustness of the server's Bridge integration. It introduces a fallback mechanism for identifying user credentials when Bridge webhooks are received, leveraging Persona accounts to match users by email if a direct ID lookup fails. Additionally, it adds retry capabilities to Bridge API calls, specifically for customer creation, to handle transient network issues or server errors more gracefully. These changes aim to reduce credential lookup failures and improve the reliability of user onboarding with Bridge. Highlights
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for GitHub and other Google products, sign up here. Footnotes
|
There was a problem hiding this comment.
Code Review
This pull request introduces a robust fallback mechanism for bridge credentials and enhances the createCustomer process with retry logic and idempotency. The changes include importing necessary utilities, modifying the bridge.ts webhook to attempt to find credentials via Persona email if the initial lookup fails, and updating the bridge.ts utility to use withRetry for customer creation. Comprehensive test cases have been added to cover the new fallback scenarios, ensuring the reliability of the system. The updates improve the resilience and error handling of the bridge integration.
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #896 +/- ##
==========================================
+ Coverage 71.56% 71.59% +0.03%
==========================================
Files 227 227
Lines 8194 8214 +20
Branches 2617 2626 +9
==========================================
+ Hits 5864 5881 +17
- Misses 2102 2104 +2
- Partials 228 229 +1
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
d143b5f to
7b6305f
Compare
Summary by CodeRabbit
New Features
Bug Fixes / Data Integrity
Tests