Skip to content

🥅 server: add retry to identity file upload#700

Merged
cruzdanilo merged 1 commit intomainfrom
retry
Jan 30, 2026
Merged

🥅 server: add retry to identity file upload#700
cruzdanilo merged 1 commit intomainfrom
retry

Conversation

@mainqueg
Copy link
Contributor

@mainqueg mainqueg commented Jan 30, 2026


Open with Devin

Summary by CodeRabbit

  • New Features

    • Identity file uploads now include automatic retry behavior with short delays and limited attempts, improving reliability during transient network errors.
  • Tests

    • Added end-to-end tests covering retry success, max-retry failure, network errors, and presigned URL failure scenarios to ensure upload robustness.

✏️ Tip: You can customize this high-level summary in your review settings.

@changeset-bot
Copy link

changeset-bot bot commented Jan 30, 2026

🦋 Changeset detected

Latest commit: 8ee587a

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@exactly/server Patch

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

@gemini-code-assist
Copy link

Summary of Changes

Hello @mainqueg, 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 identity file upload process by introducing an automatic retry mechanism. By wrapping the upload logic with viem's withRetry utility, the system can now gracefully handle transient network issues or temporary server unavailability, ensuring a more reliable and resilient file submission experience for users.

Highlights

  • Retry Mechanism for Identity File Uploads: Implemented a retry mechanism for the uploadIdentityFile function, utilizing the withRetry utility from the viem library to enhance reliability.
  • Comprehensive Error Handling: The retry logic covers failures during both the acquisition of a presigned URL and the subsequent file upload to that URL. Errors are captured using captureException within the retry callback.
  • New Test Cases: Added new unit tests to server/test/utils/manteca.test.ts to validate the retry functionality, including scenarios for successful retries, exceeding maximum retries, and handling network or server errors.
  • Changelog Entry: A new changeset file has been added to document this enhancement, ensuring proper versioning and release notes.
Using Gemini Code Assist

The 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 /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

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 .gemini/ folder in the base of the repository. Detailed instructions can be found here.

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.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

@coderabbitai
Copy link

coderabbitai bot commented Jan 30, 2026

Walkthrough

Adds retry logic around the identity file upload flow (1000ms delay, 2 retries), removes the duplicate forward outside the retry block, adds tests covering retry and error scenarios, and includes a changeset documenting a patch bump for @exactly/server.

Changes

Cohort / File(s) Summary
Implementation
server/utils/ramps/manteca.ts
Wrapped presigned URL fetch + forwarding of identity file in a retry wrapper (delay 1000ms, 2 retries); removed forwardCall outside retry; logs/captures errors on each retry.
Test Coverage
server/test/utils/manteca.test.ts
Added test suite uploadIdentityFile with 4 tests validating: retry-on-failure then success, throw after max retries, retry when fetch rejects, retry when presigned URL request initially fails. Uses attempt counters to assert retry behavior.
Changeset
.changeset/pretty-badgers-cheat.md
New changeset recording a patch bump for @exactly/server and noting addition of retry to identity file upload.

Sequence Diagram(s)

mermaid
sequenceDiagram
participant Caller as Caller
participant Server as manteca.ts
participant PresignedAPI as PresignedURL Service
participant Destination as Destination (presigned URL)
Caller->>Server: uploadIdentityFile(file)
Server->>PresignedAPI: request presigned URL
PresignedAPI-->>Server: presigned URL (or error)
alt presigned URL returned
loop retry (max 2)
Server->>Destination: forwardFileToURL (fetch PUT)
alt success
Destination-->>Server: 200 OK
Server-->>Caller: success
break
else failure
Destination-->>Server: error / network reject
Server->>Server: captureException / warn
Server-->>Server: wait 1000ms then retry
end
end
else presigned URL error
PresignedAPI-->>Server: error
Server->>Server: captureException / warn
Server-->>Caller: throws "Destination upload failed"
end

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Suggested reviewers

  • nfmelendez
  • cruzdanilo
🚥 Pre-merge checks | ✅ 2
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'server: add retry to identity file upload' directly matches the main change in the pull request—adding retry logic to identity file uploads in the server package.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch retry

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@sentry
Copy link

sentry bot commented Jan 30, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 64.47%. Comparing base (4b22d84) to head (8ee587a).
⚠️ Report is 1 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #700      +/-   ##
==========================================
+ Coverage   64.36%   64.47%   +0.11%     
==========================================
  Files         173      173              
  Lines        5391     5394       +3     
  Branches     1515     1515              
==========================================
+ Hits         3470     3478       +8     
+ Misses       1737     1731       -6     
- Partials      184      185       +1     
Flag Coverage Δ
e2e 42.89% <0.00%> (-21.14%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Copy link

@devin-ai-integration devin-ai-integration bot left a comment

Choose a reason for hiding this comment

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

✅ Devin Review: No Issues Found

Devin Review analyzed this PR and found no potential bugs to report.

View in Devin Review to see 4 additional flags.

Open in Devin Review

Copy link

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request introduces a retry mechanism for the identity file upload process using viem's withRetry utility. This is a good improvement for handling transient failures. The implementation is straightforward and new tests have been added to verify the retry logic for various failure scenarios. My main feedback is to refine the shouldRetry condition to avoid retrying on non-transient client-side errors (4xx HTTP status codes), which can mask underlying issues and add unnecessary delays.

Copy link

@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: 2

🤖 Fix all issues with AI agents
In `@server/test/utils/manteca.test.ts`:
- Around line 514-645: The `describe("uploadIdentityFile", ...)` suite is
outside the main `describe("manteca utils", ...)` so its tests don't get the
shared beforeEach/afterEach mock setup/teardown; either move the entire
describe("uploadIdentityFile", ...) block inside the existing describe("manteca
utils", ...) block so it inherits the hooks, or add explicit setup/teardown in
that file (e.g., beforeEach/afterEach calling the same setup and
vi.restoreAllMocks() / cleanup that the main block uses) to ensure mocks
(vi.spyOn(globalThis, "fetch")) are restored and tests remain isolated.

In `@server/utils/ramps/manteca.ts`:
- Around line 52-71: The shouldRetry currently always returns true in the
withRetry call wrapping request/forwardFileToURL; update it to only retry
transient/server/network errors by parsing the error returned by request (it
includes HTTP status like "::400::...") and return true for network failures or
5xx statuses (and possibly 429), but return false for client errors (400, 401,
403). Use the existing shouldRetry signature and keep captureException(error, {
level: "warning" }) for telemetry; if unconditional retry was intentional, add a
short explanatory comment in the withRetry block stating that rationale instead
of changing behavior.

@cruzdanilo cruzdanilo merged commit 8ee587a into main Jan 30, 2026
15 checks passed
@cruzdanilo cruzdanilo deleted the retry branch January 30, 2026 18:07
@sentry
Copy link

sentry bot commented Feb 6, 2026

Issues attributed to commits in this pull request

This pull request was merged and Sentry observed the following issues:

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.

2 participants