Fix Sentry WORDPRESS-ANDROID-3AA5: guard FeatureFlagsStore reads against DB errors#22828
Draft
Fix Sentry WORDPRESS-ANDROID-3AA5: guard FeatureFlagsStore reads against DB errors#22828
Conversation
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>
Collaborator
Generated by 🚫 Danger |
Contributor
|
|
Contributor
|
|
Contributor
🤖 Build Failure AnalysisThis 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 Report✅ All modified and coverable lines are covered by tests. 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. 🚀 New features to boost your workflow:
|
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>
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 join this conversation on GitHub.
Already have an account?
Sign in to comment
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.


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()andgetFeatureFlagsByKey()now catch and log read failures, returning an empty list instead of crashing.FeatureFlagValueSourceConverterbounds-checks the stored ordinal and falls back toBUILD_CONFIGfor unknown values.Test plan
BUILD_CONFIGfor unknown ordinals by runningFeatureFlagValueSourceConverterTest:FeatureFlagValueSourceConverter().toFeatureFlagValueSource(value)directly with0,1,99, and-1, asserting the out-of-range and negative inputs map toBUILD_CONFIG.