Skip to content

chore: do not throw on Zerion 404s#11364

Merged
0xApotheosis merged 2 commits intodevelopfrom
zerion-404-skip
Dec 11, 2025
Merged

chore: do not throw on Zerion 404s#11364
0xApotheosis merged 2 commits intodevelopfrom
zerion-404-skip

Conversation

@0xApotheosis
Copy link
Copy Markdown
Member

@0xApotheosis 0xApotheosis commented Dec 11, 2025

Description

Stop polluting the console with Zerion 404s. There are expected for some assets, no need to constantly throw.

Issue (if applicable)

N/A

Risk

High Risk PRs Require 2 approvals

Low

What protocols, transaction types, wallets or contract interactions might be affected by this PR?

None

Testing

You should no longer see these in the console:

Screenshot 2025-12-11 at 4 10 01 pm

Engineering

👆

Operations

  • 🏁 My feature is behind a flag and doesn't require operations testing (yet)

👆

Screenshots (if applicable)

See above.


Note

Gracefully handle Zerion 404s in getZerionTokenMarketData, returning undefined instead of throwing.

  • Market Service (Zerion)
    • Update src/lib/market-service/zerion/zerion.ts:
      • Wrap axios.get in getZerionTokenMarketData with try/catch.
      • On 404 responses, return undefined (token not found) instead of throwing; rethrow other errors.

Written by Cursor Bugbot for commit 08813af. This will update automatically on new commits. Configure here.

Summary by CodeRabbit

  • Bug Fixes
    • Improved error handling for market data retrieval. The application now gracefully manages cases where token market data is unavailable from external sources, preventing potential crashes and ensuring uninterrupted functionality during data retrieval failures.

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

@0xApotheosis 0xApotheosis requested a review from a team as a code owner December 11, 2025 05:12
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai bot commented Dec 11, 2025

📝 Walkthrough

Walkthrough

Adds try/catch error handling around the Zerion token market data API call in a single service method. The implementation gracefully returns undefined for 404 errors and rethrows other exceptions, preventing unhandled errors when tokens are missing from Zerion's database.

Changes

Cohort / File(s) Summary
Zerion API Error Handling
src/lib/market-service/zerion/zerion.ts
Wraps axios token market data fetch in try/catch block to handle 404 errors gracefully by returning undefined; other errors are rethrown

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~8 minutes

  • Verify that returning undefined on 404 is the intended behavior for missing tokens
  • Confirm error handling doesn't mask unrelated 404 responses
  • Check if any callers of this method properly handle the new undefined return value

Poem

🐰 A token dance with error grace,
Try and catch now take their place,
When Zerion says "not found" with care,
We return undefined, smooth as air!

Pre-merge checks and finishing touches

✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately describes the main change: adding error handling to skip throwing on Zerion 404 errors instead of propagating them, which aligns with the code modification of wrapping the axios call in try/catch.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
✨ 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 zerion-404-skip

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.

Copy link
Copy Markdown
Contributor

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

🧹 Nitpick comments (1)
src/lib/market-service/zerion/zerion.ts (1)

54-63: 404 handling is correct locally, but findByAssetId still throws on missing tokens

The new try/catch correctly special‑cases Zerion 404s and rethrows other errors, but findByAssetId still treats undefined from getZerionTokenMarketData as an error and throws, so callers will likely still see errors/logs for expected “token not found” cases. That may mean the PR doesn’t fully achieve the “don’t throw on Zerion 404s” objective.

To align behavior with the goal (and with the Promise<MarketData | null> signature), consider treating “no Zerion data” (404 or non‑token) as a normal null result and only letting genuine failures bubble:

   async findByAssetId({ assetId }: MarketDataArgs): Promise<MarketData | null> {
-    try {
-      const zerionMarketData = await this.getZerionTokenMarketData(assetId)
-      if (!zerionMarketData)
-        throw new Error('MarketService(findByAssetId): error fetching market data')
-
-      return zerionMarketDataToMarketData(zerionMarketData)
-    } catch (e) {
-      throw new Error(`MarketService(findByAssetId): error fetching market data: ${e}`)
-    }
+    const zerionMarketData = await this.getZerionTokenMarketData(assetId)
+    if (!zerionMarketData) return null
+
+    return zerionMarketDataToMarketData(zerionMarketData)
   }

This keeps non‑404/network errors as real exceptions (they’ll still throw out of getZerionTokenMarketData) while making expected 404s behave like “no data from this provider” instead of an error. Please double‑check this against the caller behavior and the original console noise you’re trying to eliminate.

Also applies to: 201-210

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

Disabled knowledge base sources:

  • Linear integration is disabled by default for public repositories

You can enable these sources in your CodeRabbit configuration.

📥 Commits

Reviewing files that changed from the base of the PR and between 24f0049 and 08813af.

📒 Files selected for processing (1)
  • src/lib/market-service/zerion/zerion.ts (1 hunks)
🧰 Additional context used
📓 Path-based instructions (3)
**/*.{ts,tsx,js,jsx}

📄 CodeRabbit inference engine (CLAUDE.md)

**/*.{ts,tsx,js,jsx}: Never assume a library is available - always check imports/package.json first
Prefer composition over inheritance
Write self-documenting code with clear variable and function names
Keep functions small and focused on a single responsibility
Avoid deep nesting - use early returns instead
Prefer procedural and easy to understand code
Never expose, log, or commit secrets, API keys, or credentials
Validate all inputs, especially user inputs
Handle errors gracefully with meaningful messages
Don't silently catch and ignore exceptions
Log errors appropriately for debugging
Provide fallback behavior when possible
Use appropriate data structures for the task
Never add code comments unless explicitly requested
When modifying code, do not add comments that reference previous implementations or explain what changed. Comments should only describe the current logic and functionality.
Use meaningful names for branches, variables, and functions
Always run yarn lint --fix and yarn type-check after making changes
Avoid let variable assignments - prefer const with inline IIFE switch statements or extract to functions for conditional logic

Files:

  • src/lib/market-service/zerion/zerion.ts
**/*.{ts,tsx}

📄 CodeRabbit inference engine (CLAUDE.md)

**/*.{ts,tsx}: Avoid useEffect where practical - use it only when necessary and following best practices
Avoid 'any' types - use specific type annotations instead
For default values with user overrides, use computed values (useMemo) instead of useEffect - pattern: userSelected ?? smartDefault ?? fallback
When function parameters are unused due to interface requirements, refactor the interface or implementation to remove them rather than prefixing with underscore
Sanitize data before displaying to prevent XSS
Memoize aggressively - wrap component variables in useMemo and callbacks in useCallback where possible
For static JSX icon elements (e.g., <TbCopy />) that don't depend on state/props, define them as constants outside the component to avoid re-renders instead of using useMemo
Account for light/dark mode using useColorModeValue hook
Account for responsive mobile designs in all UI components
When applying styles, use the existing standards and conventions of the codebase
Use Chakra UI components and conventions
All copy/text must use translation keys - never hardcode strings
Use the translation hook: useTranslate() from react-polyglot
Use useFeatureFlag('FlagName') hook to access feature flag values in components
Prefer type over interface for type definitions
Use strict typing - avoid any
Use Nominal types for domain identifiers (e.g., WalletId, AccountId)
Import types from @shapeshiftoss/caip for chain/account/asset IDs
Use useAppSelector for Redux state
Use useAppDispatch for Redux actions
Memoize expensive computations with useMemo
Memoize callbacks with useCallback

**/*.{ts,tsx}: Use Result<T, E> pattern for error handling in swappers and APIs; ALWAYS use Ok() and Err() from @sniptt/monads; AVOID throwing within swapper API implementations
ALWAYS use custom error classes from @shapeshiftoss/errors with meaningful error codes for internationalization and relevant details in error objects
ALWAYS wrap async op...

Files:

  • src/lib/market-service/zerion/zerion.ts
**/*.{js,jsx,ts,tsx}

📄 CodeRabbit inference engine (.cursor/rules/naming-conventions.mdc)

**/*.{js,jsx,ts,tsx}: Use camelCase for variables, functions, and methods with descriptive names that explain the purpose
Use verb prefixes for functions that perform actions (e.g., fetch, validate, execute, update, calculate)
Use UPPER_SNAKE_CASE for constants and configuration values with descriptive names
Use handle prefix for event handlers with descriptive names in camelCase
Use descriptive boolean variable names with is, has, can, should prefixes
Use named exports for components, functions, and utilities instead of default exports
Use descriptive import names and avoid renaming imports unless necessary
Avoid non-descriptive variable names like data, item, obj, and single-letter variable names except in loops
Avoid abbreviations in names unless they are widely understood
Avoid generic function names like fn, func, or callback

Files:

  • src/lib/market-service/zerion/zerion.ts
🧠 Learnings (2)
📓 Common learnings
Learnt from: NeOMakinG
Repo: shapeshift/web PR: 10231
File: src/components/AssetSearch/components/AssetList.tsx:2-2
Timestamp: 2025-08-08T15:00:49.887Z
Learning: Project shapeshift/web: NeOMakinG prefers avoiding minor a11y/UI nitpicks (e.g., adding aria-hidden to decorative icons in empty states like src/components/AssetSearch/components/AssetList.tsx) within feature PRs; defer such suggestions to a follow-up instead of blocking the PR.
Learnt from: gomesalexandre
Repo: shapeshift/web PR: 11170
File: patches/@shapeshiftoss+bitcoinjs-lib+7.0.0-shapeshift.0.patch:9-19
Timestamp: 2025-11-25T21:43:10.838Z
Learning: In shapeshift/web, gomesalexandre will not expand PR scope to fix latent bugs in unused API surface (like bitcoinjs-lib patch validation methods) when comprehensive testing proves the actual used code paths work correctly, preferring to avoid costly hdwallet/web verdaccio publish cycles and full regression testing for conceptual issues with zero runtime impact.
Learnt from: premiumjibles
Repo: shapeshift/web PR: 10361
File: src/pages/Markets/components/CardWithSparkline.tsx:83-92
Timestamp: 2025-08-25T23:32:13.876Z
Learning: In shapeshift/web PR #10361, premiumjibles considered the nested button accessibility issue (ChartErrorFallback retry Button inside Card rendered as Button in CardWithSparkline.tsx) out of scope for the error boundaries feature PR, consistent with deferring minor a11y improvements to follow-up PRs.
Learnt from: gomesalexandre
Repo: shapeshift/web PR: 10074
File: src/features/defi/providers/fox-farming/components/FoxFarmingManager/Withdraw/components/Confirm.tsx:192-194
Timestamp: 2025-07-24T10:07:54.919Z
Learning: For fox farming withdrawals in the ShapeShift web app, the architectural preference is to either not handle errors with old-style toast notifications or handle broadcast on-chain errors holistically through the action center system. On-chain errors are considered rare and not a major concern worth individual toast handling.
Learnt from: gomesalexandre
Repo: shapeshift/web PR: 10461
File: src/plugins/walletConnectToDapps/components/modals/EIP712MessageDisplay.tsx:21-24
Timestamp: 2025-09-12T13:16:27.004Z
Learning: gomesalexandre declined to add error boundaries to WalletConnect modals in PR #10461, stating "no error boundaries in this pr ser", consistent with his preference to keep PR scope focused and defer tangential improvements to separate efforts.
Learnt from: gomesalexandre
Repo: shapeshift/web PR: 10461
File: src/plugins/walletConnectToDapps/components/WalletConnectSigningModal/content/SendTransactionContent.tsx:0-0
Timestamp: 2025-09-12T10:44:46.723Z
Learning: gomesalexandre dismissed a clipboard error handling suggestion in PR #10461 for SendTransactionContent.tsx, demonstrating that the current navigator.clipboard.writeText implementation works as expected and preferring to keep it simple without additional try/catch error handling.
Learnt from: NeOMakinG
Repo: shapeshift/web PR: 10231
File: src/components/MultiHopTrade/components/TradeInput/components/HighlightedTokens.tsx:14-14
Timestamp: 2025-08-08T15:00:22.321Z
Learning: In shapeshift/web reviews for NeOMakinG, avoid nitpicks to change deep-relative imports to '@/…' alias paths within feature/non-refactor PRs; defer such style-only changes to a dedicated follow-up refactor unless they fix an issue.
📚 Learning: 2025-12-03T23:21:16.985Z
Learnt from: gomesalexandre
Repo: shapeshift/web PR: 11261
File: src/lib/utils/tron/getAllowance.ts:14-59
Timestamp: 2025-12-03T23:21:16.985Z
Learning: In src/lib/utils/tron/getAllowance.ts, gomesalexandre is not concerned about adding comprehensive error handling (try-catch blocks, custom error classes) for the getTrc20Allowance utility function, because it is used close to the view layer. He prefers simpler error handling for view-layer utilities, letting errors propagate naturally rather than adding defensive guards.

Applied to files:

  • src/lib/market-service/zerion/zerion.ts
⏰ 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). (1)
  • GitHub Check: Cursor Bugbot

Copy link
Copy Markdown
Contributor

@gomesalexandre gomesalexandre left a comment

Choose a reason for hiding this comment

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

gm

Image

@gomesalexandre gomesalexandre enabled auto-merge (squash) December 11, 2025 09:42
@0xApotheosis 0xApotheosis merged commit 023a9bc into develop Dec 11, 2025
4 checks passed
@0xApotheosis 0xApotheosis deleted the zerion-404-skip branch December 11, 2025 22:55
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