chore(runway): cherry-pick fix(predict): handle missing sports market labels cp-7.80.0#30955
Merged
Merged
Conversation
… labels cp-7.80.0 (#30946) ## **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: ```bash 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** ```gherkin 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** - [ ] I've followed [MetaMask Contributor Docs](https://github.com/MetaMask/contributor-docs) and [MetaMask Mobile Coding Standards](https://github.com/MetaMask/metamask-mobile/blob/main/.github/guidelines/CODING_GUIDELINES.md). - [ ] I've completed the PR template to the best of my ability - [ ] I've included tests if applicable - [ ] I've documented my code using [JSDoc](https://jsdoc.app/) format if applicable - [ ] I've applied the right labels on the PR (see [labeling guidelines](https://github.com/MetaMask/metamask-mobile/blob/main/.github/guidelines/LABELING_GUIDELINES.md)). Not required for external contributors. #### 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](https://consensyssoftware.atlassian.net/wiki/spaces/TL1/pages/edit-v2/401401446401?draftShareId=9d77e1e1-4bdc-4be1-9ebb-ccd916988d93) to import wallets with many accounts and tokens - [ ] I've instrumented key operations with Sentry traces for production performance metrics - See [`trace()`](/app/util/trace.ts) for usage and [`addToken`](/app/components/Views/AddAsset/components/AddCustomToken/AddCustomToken.tsx#L274) for an example For performance guidelines and tooling, see the [Performance Guide](https://consensyssoftware.atlassian.net/wiki/spaces/TL1/pages/400085549067/Performance+Guide+for+Engineers). ## **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. <!-- CURSOR_SUMMARY --> --- > [!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`. > > <sup>Reviewed by [Cursor Bugbot](https://cursor.com/bugbot) for commit f242305. Bugbot is set up for automated code reviews on this repo. Configure [here](https://www.cursor.com/dashboard/bugbot).</sup> <!-- /CURSOR_SUMMARY --> --------- Co-authored-by: Luis Taniça <matallui@gmail.com>
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. |
Contributor
🔍 Smart E2E Test Selection⏭️ Smart E2E selection skipped - PR targets a release or stable branch (release/* or stable) All E2E tests pre-selected. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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:Totalsbasketball_odd_even:Odd/Even Scorebasketball_team_to_score_first:Team to Score Firsttennis_set_handicap:Set HandicapFinally, it hardens the Polymarket parser for search/feed responses
where spread markets may omit
groupItemTitle. In that case, parsingnow falls back to
market.questionbefore formatting the spread title,preventing
replacefrom being called onundefined.Automated validation:
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
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
Docs and MetaMask Mobile
Coding
Standards.
if applicable
guidelines).
Not required for external contributors.
Performance checks (if applicable)
SRPs
to import wallets with many accounts and tokens
performance metrics
trace()for usage andaddTokenfor an example
For performance guidelines and tooling, see the Performance
Guide.
Pre-merge reviewer checklist
app, test code being changed).
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.
PredictGameOutcomesTabnow resolves sports market type labelsvia translation, then an optional outcome title fallback, then
title-cased type keys. Missing i18n (raw key or
[missingmarkers) islogged once per key through
Logger.errorinstead of showing brokencopy 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.jsonadds English strings for basketball(
basketball_total_points,basketball_odd_even,basketball_team_to_score_first) andtennis_set_handicap.Polymarket
formatMarketGroupItemTitleusesgroupItemTitle ?? question ?? ''so spread markets withoutgroupItemTitleno longerthrow 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.
Co-authored-by: Luis Taniça matallui@gmail.com a6175b9