Skip to content

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

Closed
nbradbury wants to merge 7 commits intotrunkfrom
fix/sentry-3aa5-featureflag-npe
Closed

Fix Sentry WORDPRESS-ANDROID-3AA5: guard FeatureFlagsStore reads against DB errors#22828
nbradbury wants to merge 7 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 FeatureFlagValueSourceConverterTest passes
  • Verify clean CI

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-735d388
Build Number1488
Application IDorg.wordpress.android.prealpha
Commit735d388
Installation URL09pkmuapa8bgo
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-735d388
Build Number1488
Application IDcom.jetpack.android.prealpha
Commit735d388
Installation URL757d1qf3a37n0
Automatticians: You can use our internal self-serve MC tool to give yourself access to those builds if needed.

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.21%. Comparing base (1d893fd) to head (4883c5a).
⚠️ Report is 1 commits behind head on trunk.

Additional details and impacted files
@@           Coverage Diff           @@
##            trunk   #22828   +/-   ##
=======================================
  Coverage   37.20%   37.21%           
=======================================
  Files        2317     2317           
  Lines      124509   124514    +5     
  Branches    16907    16908    +1     
=======================================
+ Hits        46324    46336   +12     
+ Misses      74438    74431    -7     
  Partials     3747     3747           

☔ 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>
nbradbury and others added 4 commits May 3, 2026 10:52
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>
Resolves DoNotMockDataClass lint error introduced by trunk merge of
PR #22785 in EditorSettingsRepositoryTest.kt.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Reverts the baseline entry added in the previous commit and fixes the
underlying DoNotMockDataClass lint error by constructing a real
ThemeWithEditContext via a test helper.

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

Closing this, will try again in a separate PR.

@nbradbury nbradbury closed this May 5, 2026
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