Skip to content

fix(perps): validate market patterns and log invalid ones to Sentry#26053

Merged
abretonc7s merged 2 commits intomainfrom
fix/perps/sentry-parsing
Feb 13, 2026
Merged

fix(perps): validate market patterns and log invalid ones to Sentry#26053
abretonc7s merged 2 commits intomainfrom
fix/perps/sentry-parsing

Conversation

@abretonc7s
Copy link
Copy Markdown
Contributor

@abretonc7s abretonc7s commented Feb 13, 2026

Description

Defense-in-depth fix to prevent a single bad LaunchDarkly pattern from crashing the perps provider or flooding Sentry with CLIENT_NOT_INITIALIZED errors.

  • Validate and filter invalid market patterns at both ingestion points (FeatureFlagConfigurationService.filterValidPatterns, HyperLiquidProvider.compilePatternsSafely) — invalid patterns are dropped and reported to Sentry
  • Fix stripQuotes to handle nested quote layers (e.g. '"xyz:TSLA"' from LaunchDarkly)

Changelog

CHANGELOG entry: null

Related issues

Fixes: Sentry CLIENT_NOT_INITIALIZED flood caused by malformed LaunchDarkly patterns

Manual testing steps

Feature: Invalid market pattern resilience

  Scenario: Provider initializes with bad patterns
    Given a HyperLiquidProvider with an invalid pattern in the allowlist

    When the provider is constructed
    Then it does not throw and valid patterns are compiled
    And the invalid pattern is logged to Sentry

  Scenario: Feature flag service filters bad remote config
    Given LaunchDarkly returns a market list containing an invalid pattern

    When FeatureFlagConfigurationService validates the list
    Then the invalid pattern is dropped
    And the valid patterns are applied
    And the invalid pattern is logged to Sentry

Screenshots/Recordings

N/A — no UI changes

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

Low Risk
Scoped defensive validation/logging changes around feature-flag parsing and pattern compilation; behavior changes mainly drop invalid patterns and avoid constructor throws.

Overview
Hardens HIP-3 market allow/blocklist handling so malformed LaunchDarkly values no longer crash perps setup: FeatureFlagConfigurationService now validates patterns via validateMarketPattern, drops invalid entries, and logs them via logger.error, falling back to the existing config when filtering produces an empty list.

HyperLiquidProvider now compiles market filters with a new compilePatternsSafely helper that skips patterns that fail compileMarketPattern and logs the error instead of throwing during construction. stripQuotes was updated to remove multiple nested quote layers, and new/expanded tests cover nested quote parsing plus invalid-pattern filtering/logging and provider resilience.

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

Bad LaunchDarkly patterns could crash the provider constructor or
flood Sentry with CLIENT_NOT_INITIALIZED errors. Filter invalid
patterns at both ingestion points (FeatureFlagConfigurationService,
HyperLiquidProvider) and report each via logger.error for prod
visibility. Also fix stripQuotes to handle nested quote layers.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@abretonc7s abretonc7s requested a review from a team as a code owner February 13, 2026 03:07
@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.

@metamaskbot metamaskbot added the team-perps Perps team label Feb 13, 2026
Copy link
Copy Markdown

@cursor cursor bot left a comment

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.

Bad LaunchDarkly patterns could crash the provider constructor or
flood Sentry with CLIENT_NOT_INITIALIZED errors. Filter invalid
patterns at both ingestion points (FeatureFlagConfigurationService,
HyperLiquidProvider) and report each via logger.error for prod
visibility. Also fix stripQuotes to handle nested quote layers.
@abretonc7s abretonc7s force-pushed the fix/perps/sentry-parsing branch from abb19a3 to 572077d Compare February 13, 2026 03:51
@github-actions
Copy link
Copy Markdown
Contributor

🔍 Smart E2E Test Selection

  • Selected E2E tags: SmokePerps, SmokeWalletPlatform, SmokeConfirmations
  • Selected Performance tags: @PerformancePreps
  • Risk Level: medium
  • AI Confidence: 85%
click to see 🤖 AI reasoning details

E2E Test Selection:
The changes are focused on defensive improvements to the Perps controller subsystem:

  1. stringParseUtils.ts: Enhanced stripQuotes to handle nested quotes from LaunchDarkly (e.g., '"xyz:TSLA"'xyz:TSLA)

  2. FeatureFlagConfigurationService.ts: Added filterValidPatterns() to validate market patterns before use, dropping invalid patterns gracefully instead of crashing

  3. HyperLiquidProvider.ts: Added compilePatternsSafely() to wrap pattern compilation in try-catch, preventing constructor crashes from bad patterns

These changes improve resilience of the Perps feature when receiving malformed configuration from LaunchDarkly. While the changes are defensive and don't alter core functionality, they affect critical initialization paths for the Perps trading feature.

Selected tags based on tag descriptions:

  • SmokePerps: Directly tests perpetuals trading functionality including Add Funds flow, balance verification, and Perps interface - all of which depend on the HyperLiquidProvider and FeatureFlagConfigurationService being properly initialized
  • SmokeWalletPlatform: Required because Perps is a section inside the Trending tab (per tag description: "changes to Perps views affect Trending")
  • SmokeConfirmations: Required because Add Funds deposits are on-chain transactions (per SmokePerps description)

Performance Test Selection:
The changes affect the HyperLiquidProvider constructor and FeatureFlagConfigurationService initialization, which are part of the Perps feature startup path. While the changes are primarily defensive (error handling), they add validation loops during pattern compilation. The @PerformancePreps tag tests perps market loading, position management, and add funds flow - all of which depend on the modified initialization code. Running this performance test will verify that the defensive changes don't introduce noticeable latency in the Perps feature.

View GitHub Actions results

@sonarqubecloud
Copy link
Copy Markdown

@abretonc7s abretonc7s added this pull request to the merge queue Feb 13, 2026
Merged via the queue into main with commit d5bb699 Feb 13, 2026
94 checks passed
@abretonc7s abretonc7s deleted the fix/perps/sentry-parsing branch February 13, 2026 06:03
@github-actions github-actions bot locked and limited conversation to collaborators Feb 13, 2026
@metamaskbot metamaskbot added the release-7.67.0 Issue or pull request that will be included in release 7.67.0 label Feb 13, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

release-7.67.0 Issue or pull request that will be included in release 7.67.0 size-M team-perps Perps team

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants