Skip to content

fix(predict): handle undefined team alias in sport card token matching#28937

Merged
caieu merged 1 commit into
mainfrom
fix/featured-carousel-sport-card-alias-crash
Apr 16, 2026
Merged

fix(predict): handle undefined team alias in sport card token matching#28937
caieu merged 1 commit into
mainfrom
fix/featured-carousel-sport-card-alias-crash

Conversation

@ghgoodreau
Copy link
Copy Markdown
Contributor

@ghgoodreau ghgoodreau commented Apr 16, 2026

Description

The FeaturedCarouselSportCard crashes with TypeError: Cannot read property 'toLowerCase' of undefined when a sport team's alias field is undefined in the API response (observed with European football teams like SC Freiburg, RC Celta de Vigo).

The fix extracts a matchesTeam helper that safely guards against undefined values on alias, name, and title before calling .toLowerCase(). The PredictSportTeam.alias type is also corrected to optional to match the actual API contract.

Changelog

CHANGELOG entry: Fixed a crash in the featured carousel when sport team alias data was missing

Related issues

Fixes:

Manual testing steps

Feature: Featured carousel sport card stability

  Scenario: Sport card renders without crashing when team alias is undefined
    Given the featured carousel contains a sport market
    And one or more teams have an undefined alias field
    When the carousel card renders
    Then the card displays without crashing
    And the correct home/away tokens are matched by team name

  Scenario: Sport card renders normally when team alias is defined
    Given the featured carousel contains a sport market
    And all teams have a defined alias field
    When the carousel card renders
    Then tokens are matched by team name or alias

Screenshots/Recordings

Before

N/A

After

N/A

Pre-merge author checklist

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

Cursor Bugbot is generating a summary for commit f5b9dfe. Configure here.

@ghgoodreau ghgoodreau requested a review from a team as a code owner April 16, 2026 17:24
@github-actions
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.

@metamaskbotv2 metamaskbotv2 Bot added the team-swaps-and-bridge Swaps and Bridge team label Apr 16, 2026
@github-actions github-actions Bot added size-S risk-low Low testing needed · Low bug introduction risk labels Apr 16, 2026
@github-actions
Copy link
Copy Markdown
Contributor

🔍 Smart E2E Test Selection

  • Selected E2E tags: SmokePredictions, SmokeWalletPlatform
  • Selected Performance tags: @PerformancePredict
  • Risk Level: low
  • AI Confidence: 90%
click to see 🤖 AI reasoning details

E2E Test Selection:
The changes are isolated to the Predict feature's FeaturedCarousel sport card component:

  1. types/index.ts: Made alias optional (alias?: string) in PredictSportTeam type - this is a type-level change reflecting that the API may not always return an alias field.

  2. FeaturedCarouselSportCard.tsx: Refactored team token matching to safely handle undefined values:

    • Extracted matchesTeam helper with null checks for tokenTitle and optional chaining for team.alias
    • Added optional chaining for t.title?.toLowerCase() in draw token search
    • These are defensive fixes preventing crashes when API data has missing fields

Tag selection rationale:

  • SmokePredictions: Directly tests the Predict/Polymarket feature including the FeaturedCarousel sport card UI. These changes affect how sport market cards display team tokens, which is core to the predictions UI.
  • SmokeWalletPlatform: Required per SmokePredictions tag description - "Predictions is also a section inside the Trending tab (SmokeWalletPlatform); changes to Predictions views affect Trending."

Risk assessment: Low risk - these are purely defensive null-safety fixes with no behavioral changes when data is well-formed. The logic change only affects edge cases where alias or title are undefined, which previously would have caused crashes.

Performance Test Selection:
The changes touch the FeaturedCarousel sport card component in the Predict feature. While the changes are minor null-safety fixes, the @PerformancePredict tag covers prediction market list loading and balance display which includes the FeaturedCarousel. However, since these are purely defensive code changes with no algorithmic complexity changes, performance impact is negligible. Selecting @PerformancePredict as a precaution to ensure the carousel rendering performance is not affected.

View GitHub Actions results

@matallui matallui added team-predict Predict team and removed team-swaps-and-bridge Swaps and Bridge team labels Apr 16, 2026
@sonarqubecloud
Copy link
Copy Markdown

@github-actions
Copy link
Copy Markdown
Contributor

E2E Fixture Validation — Schema is up to date
11 value mismatches detected (expected — fixture represents an existing user).
View details

@caieu caieu enabled auto-merge April 16, 2026 17:52
@caieu caieu added this pull request to the merge queue Apr 16, 2026
Merged via the queue into main with commit bd38182 Apr 16, 2026
286 of 290 checks passed
@caieu caieu deleted the fix/featured-carousel-sport-card-alias-crash branch April 16, 2026 19:08
@github-actions github-actions Bot locked and limited conversation to collaborators Apr 16, 2026
@metamaskbotv2 metamaskbotv2 Bot added the release-7.74.0 Issue or pull request that will be included in release 7.74.0 label Apr 16, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

release-7.74.0 Issue or pull request that will be included in release 7.74.0 risk-low Low testing needed · Low bug introduction risk size-S team-predict Predict team

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants