Skip to content

fix(predict): handle missing sports market labels cp-7.80.0#30946

Merged
matallui merged 5 commits into
mainfrom
predict/PRED-944-add-missing-translation-to-sports-markets
Jun 2, 2026
Merged

fix(predict): handle missing sports market labels cp-7.80.0#30946
matallui merged 5 commits into
mainfrom
predict/PRED-944-add-missing-translation-to-sports-markets

Conversation

@caieu

@caieu caieu commented Jun 2, 2026

Copy link
Copy Markdown
Contributor

Description

This PR fixes missing and unsafe sports market labels in Predict game details.

It adds a runtime safeguard for sports market type translations so cards no longer render i18n missing markers when Polymarket ships a new market type before the locale file is updated. When a translation is missing, the UI falls back to the outcome title; for line markets, it uses the currently selected line outcome title. Missing sports market translation keys are logged once per app session with the full i18n key so locale gaps can be discovered without spamming repeated renders.

It also adds English labels for known basketball and tennis market types:

  • basketball_total_points: Totals
  • basketball_odd_even: Odd/Even Score
  • basketball_team_to_score_first: Team to Score First
  • tennis_set_handicap: Set Handicap

Finally, it hardens the Polymarket parser for search/feed responses where spread markets may omit groupItemTitle. In that case, parsing now falls back to market.question before formatting the spread title, preventing replace from being called on undefined.

Automated validation:

yarn jest app/components/UI/Predict/components/PredictGameDetailsContent/PredictGameOutcomesTab.test.tsx app/components/UI/Predict/providers/polymarket/utils.test.ts

Result: 2 test suites passed, 88 tests passed.

Changelog

CHANGELOG entry: Fixed missing Predict sports market labels and prevented a search result parsing error for some sports markets

Related issues

Fixes: PRED-944

Manual testing steps

Feature: Predict sports market labels

  Scenario: user views a known basketball sports market
    Given the user opens a Predict basketball game details screen
    When the game contains Total Points, Odd/Even Score, or Team to Score First markets
    Then the market card titles show the localized English labels

  Scenario: user views a sports market missing a translation
    Given the user opens a Predict game details screen with an untranslated sports market type
    When the card renders
    Then the card title falls back to the outcome title instead of showing an i18n missing marker
    And the missing translation key is logged only once per app session

  Scenario: user changes lines on an untranslated line market
    Given the user opens an untranslated line market in Predict game details
    When the user selects a different line
    Then the card title updates to the selected line outcome title

  Scenario: user searches Predict markets
    Given the user is searching Predict markets
    When a spread market response is missing groupItemTitle
    Then the market parses without a runtime error
    And the spread title falls back to the market question

Screenshots/Recordings

Before

Observed missing translation markers in Predict sports market cards and a runtime parser error while searching sports markets.

After

Sports market cards render translated labels or outcome-title fallbacks, missing translation keys are logged once, and search parsing handles missing spread group titles without throwing.

Pre-merge author checklist

Performance checks (if applicable)

  • I've tested on Android
    • Ideally on a mid-range device; emulator is acceptable
  • I've tested with a power user scenario
    • Use these power-user SRPs to import wallets with many accounts and tokens
  • I've instrumented key operations with Sentry traces for production performance metrics

For performance guidelines and tooling, see the Performance Guide.

Pre-merge reviewer checklist

  • I've manually tested the PR (e.g. pull and build branch, run the app, test code being changed).
  • I confirm that this PR addresses all acceptance criteria described in the ticket it closes and includes the necessary testing evidence such as recordings and or screenshots.

Note

Low Risk
UI/i18n and defensive parsing in Predict sports flows; no auth, payments, or trading logic changes.

Overview
Improves Predict sports game details when Polymarket exposes market types or API fields before locales and parsers are fully aligned.

PredictGameOutcomesTab now resolves sports market type labels via translation, then an optional outcome title fallback, then title-cased type keys. Missing i18n (raw key or [missing markers) is logged once per key through Logger.error instead of showing broken copy on cards. Line cards use the selected line’s formatted outcome title when the market type has no translation; subgroup and flat moneyline paths pass the same fallbacks.

en.json adds English strings for basketball (basketball_total_points, basketball_odd_even, basketball_team_to_score_first) and tennis_set_handicap.

Polymarket formatMarketGroupItemTitle uses groupItemTitle ?? question ?? '' so spread markets without groupItemTitle no longer throw during search/parse; spread formatting still strips the dash before the line number.

Tests cover label fallbacks, deduped logging, UI titles for unknown types/lines, and spread parsing without groupItemTitle.

Reviewed by Cursor Bugbot for commit f242305. Bugbot is set up for automated code reviews on this repo. Configure here.

caieu added 3 commits June 2, 2026 12:10
Add fallback handling for missing sports market translations so Predict cards use outcome titles instead of rendering i18n missing markers. For line markets, use the currently selected line outcome title.

Add English labels for basketball and tennis market types, and cover translated and fallback behavior in Predict game outcome tests.
@github-actions

github-actions Bot commented Jun 2, 2026

Copy link
Copy Markdown
Contributor

CLA Signature Action: All authors have signed the CLA. You may need to manually re-run the blocking PR check if it doesn't pass in a few minutes.

@github-actions github-actions Bot added the pr-not-ready-for-e2e Skip E2E and block merging. Remove this label once the PR is ready to run the E2E tests. label Jun 2, 2026
@mm-token-exchange-service mm-token-exchange-service Bot added the team-predict Predict team label Jun 2, 2026
@caieu caieu marked this pull request as ready for review June 2, 2026 15:38
@caieu caieu requested a review from a team as a code owner June 2, 2026 15:38
@github-actions github-actions Bot added the size-M label Jun 2, 2026
@caieu caieu removed size-M pr-not-ready-for-e2e Skip E2E and block merging. Remove this label once the PR is ready to run the E2E tests. labels Jun 2, 2026
@github-actions github-actions Bot added the risk:low AI analysis: low risk label Jun 2, 2026

@cursor cursor Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, have a team admin enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit 78fe218. Configure here.

@github-actions github-actions Bot added size-M risk:medium AI analysis: medium risk and removed risk:low AI analysis: low risk labels Jun 2, 2026
@matallui matallui enabled auto-merge June 2, 2026 16:19
@github-actions

github-actions Bot commented Jun 2, 2026

Copy link
Copy Markdown
Contributor

🔍 Smart E2E Test Selection

  • Selected E2E tags: SmokePredictions, SmokeWalletPlatform, SmokeConfirmations
  • Selected Performance tags: None (no tests recommended)
  • Risk Level: medium
  • AI Confidence: 90%
click to see 🤖 AI reasoning details

E2E Test Selection:
The changes are confined to the Predict/Polymarket feature area:

  1. PredictGameOutcomesTab.tsx: Refactors getSportsMarketTypeLabel to add better fallback logic (uses fallbackTitle parameter or toTitleCase as last resort), adds missing translation logging via Logger, adds null safety guard (if (!selectedOutcome) return null), and updates SubgroupCards to use outcome title as fallback when translation is missing.

  2. utils.ts (polymarket): Bug fix - formatMarketGroupItemTitle now safely handles markets missing groupItemTitle by falling back to market.question ?? '', preventing potential crashes for spread markets.

  3. en.json: Adds new translation keys for basketball market types (basketball_total_points, basketball_odd_even, basketball_team_to_score_first) and tennis (tennis_set_handicap).

  4. Test files: Unit tests covering the new behavior.

SmokePredictions is the primary tag since these changes directly affect Polymarket prediction market UI and data parsing. Per SmokePredictions tag description, SmokeWalletPlatform (Trending section where Predictions is embedded) and SmokeConfirmations (on-chain transactions for opening/closing positions) must also be selected.

No other feature areas are affected - no changes to navigation, shared components, controllers, or other feature modules.

Performance Test Selection:
The changes are bug fixes and translation additions for the Predict/Polymarket feature. They involve logic improvements (null safety, fallback handling) and new i18n keys - not UI rendering performance, data loading, or critical path changes that would impact measurable performance metrics. No performance tests are warranted.

View GitHub Actions results

@github-actions github-actions Bot added risk:low AI analysis: low risk and removed risk:medium AI analysis: medium risk labels Jun 2, 2026
@matallui matallui added this pull request to the merge queue Jun 2, 2026
Merged via the queue into main with commit a6175b9 Jun 2, 2026
215 of 240 checks passed
@matallui matallui deleted the predict/PRED-944-add-missing-translation-to-sports-markets branch June 2, 2026 19:03
@github-actions github-actions Bot locked and limited conversation to collaborators Jun 2, 2026
@metamaskbotv2 metamaskbotv2 Bot added the release-7.81.0 Issue or pull request that will be included in release 7.81.0 label Jun 2, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

release-7.81.0 Issue or pull request that will be included in release 7.81.0 risk:low AI analysis: low risk size-M team-predict Predict team

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants