feat: support new quote api errors#7609
Conversation
…l/cowswap into feat/new-quote-errors-1
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
Warning Review limit reached
More reviews will be available in 7 minutes and 43 seconds. Learn how PR review limits work. Your organization has used up its prepaid credits, and credit purchases are no longer available. Enable the review add-on in the billing tab to keep reviews running — you're only billed for reviews past your plan's rate limits ($0.25/file). ⌛ How to resolve this issue?After more reviews become available, a review can be triggered using the We recommend that you space out your commits to avoid hitting the rate limit. 🚦 How do rate limits work?CodeRabbit enforces hourly rate limits for each developer per organization. Our paid plans include higher PR review limits than trial, open-source, and free plans. In all cases, reviews become available again over time. During sustained high-volume PR review activity, CodeRabbit may temporarily slow when the next review becomes available. Please see our Fair Usage Limits Policy for further information. ℹ️ Review info⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (3)
WalkthroughRefactors the quote API error model by replacing the legacy operator-error mapping with a simplified ChangesQuote API Error Model Refactor and UI Wiring
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Possibly related PRs
Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 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 |
|
|
||
| // Conforms to backend API | ||
| // https://github.com/cowprotocol/services/blob/main/crates/orderbook/openapi.yml | ||
| // TODO: import from SDK `PriceEstimationError.errorType` |
There was a problem hiding this comment.
Deploying explorer-dev with
|
| Latest commit: |
da5625a
|
| Status: | ✅ Deploy successful! |
| Preview URL: | https://e0d7c32a.explorer-dev-dxz.pages.dev |
| Branch Preview URL: | https://feat-new-quote-errors-1.explorer-dev-dxz.pages.dev |
Deploying swap-dev with
|
| Latest commit: |
da5625a
|
| Status: | ✅ Deploy successful! |
| Preview URL: | https://5e87c473.swap-dev-5u6.pages.dev |
| Branch Preview URL: | https://feat-new-quote-errors-1.swap-dev-5u6.pages.dev |
✅ AI Review (Codex GPT-5, worked 1m): follow-up acknowledgedRechecked
Result: The Sentry finding is fixed. The weekend/RWA override still only handles |
kernelwhisperer
left a comment
There was a problem hiding this comment.
Just 1 minor issue regarding UNHANDLED_ERROR_CODE usage
… feat/new-quote-errors-1 # Conflicts: # apps/cowswap-frontend/src/api/cowProtocol/errors/QuoteError.ts # apps/cowswap-frontend/src/locales/en-US.po # apps/cowswap-frontend/src/modules/tradeFormValidation/pure/QuoteApiErrorButton.pure.tsx # apps/cowswap-frontend/src/modules/tradeFormValidation/pure/QuoteErrorsButton/QuoteErrorsButton.pure.tsx # apps/cowswap-frontend/src/modules/tradeFormValidation/pure/QuoteErrorsButton/quoteErrors.utils.ts
There was a problem hiding this comment.
🧹 Nitpick comments (1)
apps/cowswap-frontend/src/api/cowProtocol/errors/QuoteError.ts (1)
42-45: ⚡ Quick winExport the unhandled-error sentinel to avoid string-literal drift across modules.
apps/cowswap-frontend/src/modules/tradeFormValidation/pure/QuoteApiErrorButton.pure.tsxcurrently checks'UNHANDLED_ERROR'as a raw literal. Keeping this sentinel private here makes that cross-file contract brittle. Export the constant(s) and reuse them in UI branches.Suggested patch
-const UNHANDLED_ERROR_CODE = 'UNHANDLED_ERROR' as const +export const UNHANDLED_ERROR_CODE = 'UNHANDLED_ERROR' as const -const UNHANDLED_ERROR_DESC = +export const UNHANDLED_ERROR_DESC = 'Quote fetch failed. This may be due to a server or network connectivity issue. Please try again later.'🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@apps/cowswap-frontend/src/api/cowProtocol/errors/QuoteError.ts` around lines 42 - 45, Export the UNHANDLED_ERROR_CODE constant from QuoteError.ts so it can be reused across modules. Update the import in QuoteApiErrorButton.pure.tsx to import UNHANDLED_ERROR_CODE from QuoteError.ts and use it in the conditional check instead of the hardcoded string literal 'UNHANDLED_ERROR'. This ensures the sentinel value is defined in a single place and referenced consistently, eliminating string-literal drift between files.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Nitpick comments:
In `@apps/cowswap-frontend/src/api/cowProtocol/errors/QuoteError.ts`:
- Around line 42-45: Export the UNHANDLED_ERROR_CODE constant from QuoteError.ts
so it can be reused across modules. Update the import in
QuoteApiErrorButton.pure.tsx to import UNHANDLED_ERROR_CODE from QuoteError.ts
and use it in the conditional check instead of the hardcoded string literal
'UNHANDLED_ERROR'. This ensures the sentinel value is defined in a single place
and referenced consistently, eliminating string-literal drift between files.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro
Run ID: c51837e1-e381-42fc-954f-8b71bcec5d24
📒 Files selected for processing (9)
apps/cowswap-frontend/src/api/cowProtocol/errors/QuoteError.tsapps/cowswap-frontend/src/api/cowProtocol/getIsOrderBookTypedError.tsapps/cowswap-frontend/src/locales/en-US.poapps/cowswap-frontend/src/modules/swap/containers/SwapWidget/index.tsxapps/cowswap-frontend/src/modules/tradeFormValidation/hooks/useTokenCustomTradeError.tsapps/cowswap-frontend/src/modules/tradeFormValidation/pure/QuoteApiErrorButton.pure.tsxapps/cowswap-frontend/src/modules/tradeFormValidation/pure/QuoteErrorsButton/quoteErrors.utils.tsapps/cowswap-frontend/src/modules/tradeQuote/services/fetchAndProcessQuote.test.tsapps/cowswap-frontend/src/modules/tradeQuote/services/fetchAndProcessQuote.ts
|
Since the PR is merged, opened #7644 with related questions |
Summary
Initially, this PR goal is to support and display the new
/quoteAPI errors added in cowprotocol/services#4268.Changes
QuoteApiErrorCodesnow lists the full set of new API codes (NoLiquidity,SellAmountDoesNotCoverFee,TokenTemporarilySuspended,TradingOutsideAllowedWindow,CustomSolverError, etc.). The old operator→quote error mapper (mapOperatorErrorToQuoteError) and the legacy codes it produced (FeeExceedsFrom,ZeroPrice,TransferEthToContract,UNHANDLED_ERRORenum member) are removed —QuoteApiErroris now constructed straight from the API error body.getIsQuoteApiTypedError()for quote API errors;getIsOrderBookTypedError()is now properly typed (unknowninstead ofany).QuoteApiErrorfrom the raw error string: the original error is kept inmessage(for logging/Sentry), whiledescriptioncarries the generic user-facing copy.getQuoteErrorTexts()is now aPartialrecord).descriptionis surfaced in a help tooltip next to the error label, so users/support can still see the underlying reason.SENTRY_IGNORED_QUOTE_ERRORSwith errors that are expected to happen regularly (InsufficientLiquidity,SellAmountDoesNotCoverFee,TokenTemporarilySuspended,TradingOutsideAllowedWindow,UnsupportedToken).To Test
SellAmountDoesNotCoverFeehandling)You can mock the API response executing the script in the browser console (no need to refresh page after, just change sell amount):
With that you should see:

Summary by CodeRabbit
New Features
Bug Fixes
Localization