Repository navigation
fix(flags): read an empty variant as disabled in getFeatureFlagResult and onFeatureFlags - #949
Merged
turnipdabeets merged 5 commits intoNov 9, 2026
Conversation
… and onFeatureFlags
This was referenced Nov 6, 2026
turnipdabeets
marked this pull request as ready for review
November 6, 2026 20:31
Contributor
posthog-android Compliance ReportDate: 2026-11-08T20:10:04.686966+00:00 ✅ All Tests Passed!232/232 tests passed Capture_V1 Tests✅ 105/105 tests passed View Details
Capture_Ai_V1 Tests✅ 110/110 tests passed View Details
Feature_Flags Tests✅ 17/17 tests passed View Details
|
This was referenced Nov 6, 2026
…_flags Applies to PostHog and PostHogStateless. $feature/<key> still carries the raw "" value, matching posthog-js. posthog-server builds its own flag properties and already left "" out.
marandaneto
approved these changes
Nov 9, 2026
5 of 15 tasks
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.
💡 Motivation and Context
A flag whose variant is the empty string
""already reads as disabled fromisFeatureEnabled()(since 3.x), butgetFeatureFlagResult().enabledwastrueandPostHogFeatureFlagsLoadedlisted the flag, so the same flag read as enabled and disabled depending on the call. posthog-ios had the same split after posthog-ios#1001 (review thread); posthog-js (browser) is already consistent. This makes""read as disabled everywhere.getFeatureFlagResult()andgetAllFeatureFlags()returnenabled = false, withvariantstill"".PostHogFeatureFlagsLoadedleaves the flag out offlagsandvariants.PostHogandPostHogStateless, only whensendFeatureFlagEventis on, as before) leave the flag out of$active_feature_flags;$feature/<key>still carries the raw"", as in posthog-js (browser).posthog-serverbuilds these properties itself and already left""out, so it's unchanged.isFeatureEnabled()(alreadyfalse, with or withoutdefaultValue),getFeatureFlag()(still returns"", sinceFeatureFlagResult.valueisvariant ?: enabled), and$feature_flag_called(still reports$feature_flag_response: "").Blast radius is small: since PostHog/posthog#118803 (2026-10-16) PostHog rejects new
""variant keys, so only flags created earlier through the API, MCP or Terraform can hit this.Added a Breaking entry to the 4.0 changeset and an "Empty variants read as disabled" section to
docs/migration-3.x-to-4.0.md.Not changed here:
posthog-serverhas the same split (PostHogFeatureFlags.getFeatureFlagResultreturnsenabled = truefor"", whileisFeatureEnabledreturnsfalse); it's left for a follow-up.Sibling PRs:
💚 How did you test it?
PostHogFeatureFlagsTest"an empty variant reads as disabled":isFeatureEnabledwith and withoutdefaultValue,getFeatureFlagResultenabled/variant, and the reload callback'sPostHogFeatureFlagsLoaded.flags. It fails on the pre-fix source (result.enabled) and passes with the fix.PostHogTest"captured events leave a flag with an empty variant out of active_feature_flags" and an empty-variant flag inPostHogStatelessTest"captureStateless handles feature flags when enabled": both fail on the pre-fix source (the""flag is listed) and pass with the fix../gradlew spotlessCheck :posthog:test apiCheck --no-daemon --no-configuration-cache: 1251 tests, 0 failures; spotless and apiCheck pass.📝 Checklist
If releasing new changes
pnpm changesetto generate a changeset file (edited the existing 4.0 changeset)🤖 Agent context
Autonomy: Human-driven (agent-assisted)
Claude Code made the change across iOS, Android, Flutter and sdk-specs at Anna's direction. The fix is one condition in the client result builder and one in
PostHogFeatureFlagsLoaded.🤖 Generated with Claude Code