Skip to content

Conversation

jasbanza
Copy link
Member

What is the purpose of the change:

This pull request improves the user experience for bridge transfers by providing clearer error handling and more informative feedback when transfer amounts are too low due to fees or value loss. It adds logic to detect and explain insufficient fee and value loss scenarios, extracts fee details from error messages, and updates localization files to support new, more descriptive error messages.

Linear Task

FE-1504: Improve error message for insufficient tx fee

Brief Changelog

Error handling and user feedback improvements:

  • Added logic in useBridgeQuotes.ts to detect when the transfer amount is too low due to excessive value loss, distinguishing this case from insufficient fee errors. The UI now displays a specific error message when this occurs. (packages/web/components/bridge/use-bridge-quotes.tsR395-R436, F905f6fbL812R812)
  • Improved detection of insufficient fee errors by parsing error messages for fee details using the new extractFeeDetailsFromError utility, allowing the UI to display the exact fee amount and currency required. [1] [2]
  • Updated conditions for enabling transfer actions and button text to properly account for both insufficient fee and value loss error states, preventing users from proceeding when these errors are present. [1] [2] [3]

Testing and utility functions:

  • Added comprehensive unit tests for the extractFeeDetailsFromError function to verify correct parsing of fee details from various error message formats and handling of invalid formats.

Localization updates:

  • Extended localization files for multiple languages to include new messages for insufficient fee (with fee details) and value loss errors, ensuring users receive clear and actionable feedback in their preferred language. [1] [2] [3] [4] [5] [6] [7] [8] [9] [10] [11] [12]

Testing and Verifying

This change has been tested locally by rebuilding the website and verified content and links are expected

jasbanza and others added 11 commits October 14, 2025 18:40
- Enhanced isInsufficientFee detection to catch more error patterns from bridge providers
- Added fee amount extraction from error messages (e.g. '16.36 USD')
- Added isUnsupportedRoute detection for unsupported bridge routes
- Added user-friendly error messages with specific guidance
- Falls back to generic message when fee amount cannot be extracted

This fixes errors like 'InsufficientAmountError' from falling through to the
generic 'Something isn't working' message.
- Translated insufficientAmountForBridge error messages
- Translated unsupportedBridgeRoute error messages
- Covers 16 locales: de, es, fa, fr, gu, hi, ja, ko, pl, pt-br, ro, ru, tr, zh-cn, zh-hk, zh-tw
- All translations include dynamic fee amount support
- Created isInsufficientAmountForBridge for when transfer amount is too low for bridge fees
- Kept isInsufficientFee for when user has insufficient balance to pay network fees
- Both scenarios now handled with appropriate error messages
- Restored insufficientFundsForFees and youNeedFundsToPay keys for balance errors
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
- Merge newer logic check isInsufficientAmountForBridge and existing isInsufficientFee into single check
- Simplify error message logic by combining duplicate cases
- Remove isUnsupportedRoute error handling (this was added by AI but is beyond scope of this issue, we can revisit later)
- Update localization keys to match consolidated error handling
- Remove insufficientAmountForBridge, insufficientAmountForBridgeDescription, insufficientAmountForBridgeWithFee
- Remove unsupportedBridgeRoute and unsupportedBridgeRouteDescription (AI added this, beyond current scope, removing for now and can revisit later)
- Add youNeedFundsToPayWithFee with proper translations
- All 16 non-English languages updated: de, es, fa, fr, gu, hi, ja, ko, pl, pt-br, ro, ru, tr, zh-cn, zh-hk, zh-tw
- Add isValueLossTooHigh check to detect Skip's USD value difference error
- Update isInsufficientFee to exclude value loss errors (handled separately)
- Add transferAmountTooLowValueLoss and valueLossTooHighToBridge localization keys
- Update error display and button disable logic to handle value loss errors
- All 17 languages updated with appropriate translations
Copy link

vercel bot commented Oct 14, 2025

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Preview Comments Updated (UTC)
osmosis-frontend Ready Ready Preview Comment Oct 14, 2025 10:26pm
4 Skipped Deployments
Project Deployment Preview Comments Updated (UTC)
osmosis-frontend-datadog Ignored Ignored Oct 14, 2025 10:26pm
osmosis-frontend-dev Ignored Ignored Oct 14, 2025 10:26pm
osmosis-frontend-edgenet Ignored Ignored Oct 14, 2025 10:26pm
osmosis-testnet Ignored Ignored Oct 14, 2025 10:26pm

Copy link
Contributor

coderabbitai bot commented Oct 14, 2025

Walkthrough

Introduces a new fee-parsing utility and its tests, and updates the bridge quote hook to detect high value loss and insufficient fee conditions, integrate structured fee extraction from errors, and adjust control flow and UI-enabling logic accordingly.

Changes

Cohort / File(s) Summary
Tests: parse-fee utility
packages/web/__tests__/parse-fee.spec.ts
Adds tests validating extractFeeDetailsFromError across valid and invalid fee message formats, covering multiple currencies and numeral styles.
Utils: fee parsing
packages/web/utils/parse-fee.ts
Adds FeeDetails type and extractFeeDetailsFromError(message) to parse amount and currency from error strings using regex patterns and normalization.
Bridge quotes flow updates
packages/web/components/bridge/use-bridge-quotes.ts
Adds value-loss and fee-sufficiency checks, integrates extractFeeDetailsFromError, extends error pattern recognition, updates enablement and messaging logic for quotes and transfers.

Sequence Diagram(s)

sequenceDiagram
  actor User
  participant UI as UI (Bridge)
  participant Hook as useBridgeQuotes
  participant API as Bridge Provider
  participant Util as extractFeeDetailsFromError

  User->>UI: Initiate quote / transfer
  UI->>Hook: fetchQuote(params)
  Hook->>API: Request quote
  API-->>Hook: Response or Error

  alt Error indicates high value loss
    Hook->>Hook: isValueLossTooHigh = true
    Hook-->>UI: Return value-loss error state<br/>Disable actions
  else Error indicates insufficient fee
    Hook->>Util: Parse fee details from error
    Util-->>Hook: { amount, currency } or null
    Hook-->>UI: Return insufficient-fee state<br/>Include parsed details when available
  else Success
    Hook-->>UI: Quote result<br/>Enable actions
  end
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Pre-merge checks and finishing touches

❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Title Check ⚠️ Warning The title does reference the primary change of improving error messages for insufficient fees but includes unnecessary context such as the author’s name and branch identifier and uses the abbreviation “tx,” making it verbose and less clear than a standard concise summary. A streamlined title focusing solely on the functional change would better adhere to repository conventions. Rename the pull request to remove the branch and author prefix and expand abbreviations, for example: “Improve error messages for insufficient transaction fees.”
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed The pull request description follows the repository’s template by including a clear purpose section, a linked Linear task, a detailed changelog, and testing verification, each under the correct headings. The description provides sufficient context, specific change details, and confirmation of local testing, making it comprehensive and well-structured.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.
✨ 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 jason/fe-1504-improve-error-message-for-insufficient-tx-fee

📜 Recent review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between c609158 and 88687a9.

⛔ Files ignored due to path filters (17)
  • packages/web/localizations/de.json is excluded by !**/*.json
  • packages/web/localizations/en.json is excluded by !**/*.json
  • packages/web/localizations/es.json is excluded by !**/*.json
  • packages/web/localizations/fa.json is excluded by !**/*.json
  • packages/web/localizations/fr.json is excluded by !**/*.json
  • packages/web/localizations/gu.json is excluded by !**/*.json
  • packages/web/localizations/hi.json is excluded by !**/*.json
  • packages/web/localizations/ja.json is excluded by !**/*.json
  • packages/web/localizations/ko.json is excluded by !**/*.json
  • packages/web/localizations/pl.json is excluded by !**/*.json
  • packages/web/localizations/pt-br.json is excluded by !**/*.json
  • packages/web/localizations/ro.json is excluded by !**/*.json
  • packages/web/localizations/ru.json is excluded by !**/*.json
  • packages/web/localizations/tr.json is excluded by !**/*.json
  • packages/web/localizations/zh-cn.json is excluded by !**/*.json
  • packages/web/localizations/zh-hk.json is excluded by !**/*.json
  • packages/web/localizations/zh-tw.json is excluded by !**/*.json
📒 Files selected for processing (3)
  • packages/web/__tests__/parse-fee.spec.ts (1 hunks)
  • packages/web/components/bridge/use-bridge-quotes.ts (7 hunks)
  • packages/web/utils/parse-fee.ts (1 hunks)
🧰 Additional context used
🧬 Code graph analysis (2)
packages/web/components/bridge/use-bridge-quotes.ts (2)
packages/bridge/src/errors.ts (1)
  • BridgeError (20-27)
packages/web/utils/parse-fee.ts (1)
  • extractFeeDetailsFromError (15-37)
packages/web/__tests__/parse-fee.spec.ts (1)
packages/web/utils/parse-fee.ts (1)
  • extractFeeDetailsFromError (15-37)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (4)
  • GitHub Check: Cursor Bugbot
  • GitHub Check: Summary
  • GitHub Check: Analyze (javascript)
  • GitHub Check: preview-trade-tests

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.

errorMsg.includes("difference in usd value")
) {
return false; // This is value loss, not insufficient fee
}
Copy link

Choose a reason for hiding this comment

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

Bug: Bridge Error Classification Inconsistency

A logical gap exists between isInsufficientFee and isValueLossTooHigh. isInsufficientFee broadly excludes errors containing "difference in usd value", while isValueLossTooHigh only includes those also containing "too large". This leaves some bridge errors unclassified, preventing appropriate user feedback.

Fix in Cursor Fix in Web

Copy link
Member Author

Choose a reason for hiding this comment

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

More scenarios need classifying as per above

@jasbanza
Copy link
Member Author

A few scenarios. All for "InsufficientAmountError" reported by bridges:

Scenario A (Skip specific) - User inputs amount lower than bridge requires for fees:

image

Scenario B (Skip specific) - User inputs amount slightly higher than bridge requires... resulting in the bridge responding with an error. UI handles this too. Note: The actual error from the bridge is not that great since it is complaining about slippage but the bridge decides to prevent the bridge altogether.

image

@JohnnyWyles @fabryscript

This gives some better info for skip bridge fee issues. I will contribute in additional linear tasks to cover additional scenarios I've discovered while testing this:

  • Axelar specific errors
  • I've identified an issue where there's a race for 2 bridge quotes (Axelar & Skip). The Skip one returns nice response info, the Axelar response is nonsensical, but because it returns last the UX updates with the catch-all generic error.

Note that the 2nd scenario shown above is due to the bridge provider returning the following, and I think it should somehow still let the user continue with the checkbox override if they choose to accept the losses.

{
    "error": {
        "json": {
            "message": "(Skip) InsufficientAmountError: Fetch error. Difference in USD value of route input and output is too large. Input USD value: 19.66 Output USD value: 12.67.",
            "code": -32603,
            "data": {
                "code": "INTERNAL_SERVER_ERROR",
                "httpStatus": 500,
                "path": "bridgeTransfer.getQuoteByBridge",
                "zodError": null
            }
        }
    }
}

However, sometimes there's a second response JUST AFTER the Skip one above, which results in the UI quickly updating with nonsense generic error messages again. Clearly there is room for improvement with the synchronization or bridge priority.

image
{
    "error": {
        "json": {
            "message": "(Axelar) InsufficientAmountError: Negative output amount -82,775 for asset in: 17,395 WBTC.eth.axl",
            "code": -32603,
            "data": {
                "code": "INTERNAL_SERVER_ERROR",
                "httpStatus": 500,
                "path": "bridgeTransfer.getQuoteByBridge",
                "zodError": null
            }
        }
    }
}

@JohnnyWyles
Copy link
Contributor

Which assets should be getting tested here?
BTC - already has a similar error message in main ✅
SOL - still gives a vague "something isn't working" ⌛
ETH - Triggered this error with ETH ($4 fee) from $4.01 to 40 - Fee changed during testing :/

However, this generic message still completely blocks the transfer. I think the custom message here should be a more unique form of the "slippage too high" warning that still allows transfers rather than. Technically the bridge would work but just result in high loss if the box was not greyed out.

image vs
image

@jasbanza
Copy link
Member Author

@JohnnyWyles @fabryscript

Thanks for the feedback. I'm having further realizations now about this, so I'll add my revised suggestions of what needs to be done here, also for my own clarity.

Let me first address the quick answers:

  • It's not asset specific, but bridge provider specific.
  • These are only handling SKIP, not Axelar, int3, nomic, or whatever other bridge provider errors we get back. Those would need to be done in addition to this.
  • I do agree that this should be in the expanded preview section.

On to the meatier stuff:

What I currently did here is I added a couple of checks for SKIP bridge responses treating them as "errors" since that is how they are currently being returned from the edge function. For example, with the ETH swap example in your screenshot (~$40 one), where it says "Transfer amount too low", this is what is actually this being returned from the edge function:

"message": "(Skip) InsufficientAmountError: Fetch error. Difference in USD value of route input and output is too large. Input USD value: 10.59 Output USD value: 8.88. ...without any of the following SUCCESS json response information, as would normally be the case if the slippage was slightly lower - if I try with a larger ~$20 amount (or in your case the ~$30 one):

Screenshot 2025-10-18 at 10 29 38

I'm not sure it can be treated the same, since the error one doesn't return actual data (besides 2 amounts), unless in our edge function we are just not forwarding this to the frontend response. 👈 I need to investigate this! If the info is there, then it should be returned the same and we can proceed with the normal user override in the preview, but why is it different in the first place 🤔

Also note, we will always need to parse bridge errors. Ideally all bridges would give us a perfectly written user-friendly message, for every language, but they don't.

Axelar's error is a bit worse than Skips, but totally parsable, just requires more work to cover all bridges and it's a WIP so I don't think we should wait for all errors to be resolve, but rather decide on the best way forward to handling and maintaining this long term.

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