Skip to content

Fix Sentry WORDPRESS-ANDROID-3AA5: guard FeatureFlagsStore reads against DB errors#22828

Draft
nbradbury wants to merge 4 commits intotrunkfrom
fix/sentry-3aa5-featureflag-npe
Draft

Fix Sentry WORDPRESS-ANDROID-3AA5: guard FeatureFlagsStore reads against DB errors#22828
nbradbury wants to merge 4 commits intotrunkfrom
fix/sentry-3aa5-featureflag-npe

Conversation

@nbradbury
Copy link
Copy Markdown
Contributor

@nbradbury nbradbury commented May 1, 2026

Fixes WORDPRESS-ANDROID-3AA5

Summary

Defensive fix for Sentry WORDPRESS-ANDROID-3AA5 — NPE inside FeatureFlagConfigDao_Impl.getFeatureFlagList (152 users, 16k events). Same shape as the RemoteConfig DAO crash (#22826).

  • FeatureFlagsStore.getFeatureFlags() and getFeatureFlagsByKey() now catch and log read failures, returning an empty list instead of crashing.
  • FeatureFlagValueSourceConverter bounds-checks the stored ordinal and falls back to BUILD_CONFIG for unknown values.

Test plan

  • App boots normally on a healthy install (existing flag behaviour unchanged).
  • Verify the converter falls back to BUILD_CONFIG for unknown ordinals by running FeatureFlagValueSourceConverterTest:
    ./gradlew :libs:fluxc:testDebugUnitTest --tests "org.wordpress.android.fluxc.persistence.FeatureFlagValueSourceConverterTest"
    
    The test class calls FeatureFlagValueSourceConverter().toFeatureFlagValueSource(value) directly with 0, 1, 99, and -1, asserting the out-of-range and negative inputs map to BUILD_CONFIG.

Sentry WORDPRESS-ANDROID-3AA5 (152 users, 16k events): NPE inside
FeatureFlagConfigDao_Impl.getFeatureFlagList. Same shape as the
RemoteConfig DAO crash — Room can't materialize a row when the DB
is corrupt or a stored ordinal is out of range.

Wrap reads in FeatureFlagsStore so a failure degrades to an empty
list instead of crashing app startup, and harden the type converter
to fall back to BUILD_CONFIG on unknown ordinals.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@dangermattic
Copy link
Copy Markdown
Collaborator

1 Message
📖 This PR is still a Draft: some checks will be skipped.

Generated by 🚫 Danger

@wpmobilebot
Copy link
Copy Markdown
Contributor

wpmobilebot commented May 1, 2026

App Icon📲 You can test the changes from this Pull Request in WordPress Android by scanning the QR code below to install the corresponding build.

App NameWordPress Android
Build TypeDebug
Versionpr22828-c7ff422
Build Number1488
Application IDorg.wordpress.android.prealpha
Commitc7ff422
Installation URL7kol1spu5q8e0
Automatticians: You can use our internal self-serve MC tool to give yourself access to those builds if needed.

@wpmobilebot
Copy link
Copy Markdown
Contributor

wpmobilebot commented May 1, 2026

App Icon📲 You can test the changes from this Pull Request in Jetpack Android by scanning the QR code below to install the corresponding build.

App NameJetpack Android
Build TypeDebug
Versionpr22828-c7ff422
Build Number1488
Application IDcom.jetpack.android.prealpha
Commitc7ff422
Installation URL2hlnc8s5it19g
Automatticians: You can use our internal self-serve MC tool to give yourself access to those builds if needed.

@wpmobilebot
Copy link
Copy Markdown
Contributor

🤖 Build Failure Analysis

This build has failures. Claude has analyzed them - check the build annotations for details.

Detekt flagged catch(Exception) in getFeatureFlags and
getFeatureFlagsByKey. Both catches are intentionally broad — Room can
throw SQLiteException, IllegalArgumentException, or NullPointerException
depending on the failure mode, and we want all of them to degrade to
an empty list. Use the same @Suppress("TooGenericExceptionCaught")
annotation already used elsewhere in the codebase for this pattern.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@codecov
Copy link
Copy Markdown

codecov Bot commented May 1, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 37.15%. Comparing base (4ae4042) to head (c7ff422).

Additional details and impacted files
@@           Coverage Diff           @@
##            trunk   #22828   +/-   ##
=======================================
  Coverage   37.15%   37.15%           
=======================================
  Files        2314     2314           
  Lines      124323   124328    +5     
  Branches    16892    16893    +1     
=======================================
+ Hits        46187    46199   +12     
+ Misses      74390    74383    -7     
  Partials     3746     3746           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Cover the two store catches (getFeatureFlags, getFeatureFlagsByKey
returning empty list when the DAO throws) and the converter's
out-of-range/negative ordinal fallback to BUILD_CONFIG.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Mock AppLog statically so the tests assert the tag, message, and
throwable reach the log call, not just that an empty list is returned.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants