fix: tighten cow-fi content links and remote token parsing#7619
fix: tighten cow-fi content links and remote token parsing#7619fairlighteth wants to merge 4 commits into
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (9)
WalkthroughThis PR transitions token numeric market fields from string to number types throughout the entire data pipeline: type definitions, a new validation/normalization layer, token service integration, and consuming utilities and components. All changes add defensive runtime validation and type safety for price, volume, market cap, and related metrics. ChangesToken Numeric Type Safety Initiative
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes 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 docstrings
🧪 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 |
Deploying explorer-dev with
|
| Latest commit: |
15c5be2
|
| Status: | ✅ Deploy successful! |
| Preview URL: | https://460a275e.explorer-dev-dxz.pages.dev |
| Branch Preview URL: | https://deepsec-medium-03-cowfi-cont.explorer-dev-dxz.pages.dev |
Deploying swap-dev with
|
| Latest commit: |
15c5be2
|
| Status: | ✅ Deploy successful! |
| Preview URL: | https://849807dd.swap-dev-5u6.pages.dev |
| Branch Preview URL: | https://deepsec-medium-03-cowfi-cont.swap-dev-5u6.pages.dev |
fairlighteth
left a comment
There was a problem hiding this comment.
⚠️ AI Review (Codex GPT-5, worked 3m 59s): invalid Ethereum platform now crashes token pages
Finding: Invalid or missing ethereum platform data now crashes the token page
- Location:
apps/cow-fi/components/ChartSection/index.tsx:28 - This PR correctly drops malformed platform entries in
normalizePlatforms(), butChartSectionstill assumesplatforms.ethereumalways exists. - If a remote token payload has an invalid/missing
detail_platforms.ethereumentry,platforms.ethereumbecomesundefined, andplatforms.ethereum.contractAddressthrows before the chart can fall back. - Impact: the token page no longer fails closed for the malformed payloads this PR is trying to harden against.
Suggested fix
- Guard the chart path with optional chaining or a local
const ethereumAddress = platforms.ethereum?.contractAddressso missing Ethereum data skips the query instead of crashing. - Add a focused test for a token whose Ethereum platform is invalid/missing while another platform remains valid.
Review scope and related context
This is separate from existing review comments, which currently only contain deploy/bot messages. I also checked the other platform consumers here: SwapWidget and the swap-link cards already use optional access, so this assumption appears isolated to ChartSection.
🤖 Prompt for AI agents
Verify this finding against current code. Fix only if still valid, keep the change minimal, and validate with the targeted tests.
Context:
- apps/cow-fi/components/ChartSection/index.tsx:28
- normalizePlatforms() now removes malformed ethereum entries instead of preserving a placeholder object
- platforms.ethereum.contractAddress throws when ethereum is missing
- expected fix: skip the chart query when ethereum is absent, and add coverage for invalid/missing ethereum platform data
- skip the Ethereum price query when a token has no valid Ethereum platform entry - add regression coverage for token pages that keep non-Ethereum platforms after validation
fairlighteth
left a comment
There was a problem hiding this comment.
✅ AI Review (Codex GPT-5, worked 1m 10s): follow-up addressed
Rechecked
- Author response: added
fix: avoid cow-fi chart crashes on invalid token platformsin14e60784ba9debb9949e179e1b2320279e64d8fe. - Code path:
apps/cow-fi/components/ChartSection/index.tsx:26. - Test coverage:
apps/cow-fi/components/ChartSection/index.test.tsxandNX_DAEMON=false ./node_modules/.bin/nx run cow-fi:test --runInBand --testPathPatterns=apps/cow-fi/components/ChartSection/index.test.tsx.
Result: Fixed. ChartSection now reads platforms.ethereum?.contractAddress through a guarded local variable, so missing/invalid Ethereum platform data skips the query instead of throwing, and the new test covers that malformed-platform case.
🤖 Verification notes for AI agents
Verify the prior finding against current code only. Confirm whether the author's claimed fix addresses the specific failure mode, and avoid reopening broader or unrelated issues.
Prior finding:
- ChartSection crashed when normalizePlatforms() dropped an invalid ethereum entry and the code still dereferenced platforms.ethereum.contractAddress.
Current verification:
- ChartSection now guards ethereumAddress via optional access before building queryVariables.
- Added a focused test that renders with only a base platform and asserts the component does not throw and skips the query.




Summary
Addresses the remaining smaller cow-fi MEDIUM findings around external content links and remote token payload trust.
This PR keeps the token pages working, but stops trusting malformed remote token data:
null.To Test
NX_DAEMON=false ./node_modules/.bin/nx run cow-fi:test --runInBandpasses.NX_DAEMON=false ./node_modules/.bin/nx run cow-fi:lint --verbosecompletes with 0 errors.https://rather thanhttp://./tokens/[tokenId]and confirm metadata and swap-link data still render.null/unavailable state rather than crashing the page.Background
The report grouped these items together because they were all content-trust issues in cow-fi rather than app-flow issues.
The biggest part is the token-content boundary: remote token JSON is still allowed, but only after its required fields and platform addresses pass validation.
Summary by CodeRabbit