Skip to content

fix: support fractional rollout percentages in local evaluation - #699

Merged
marandaneto merged 3 commits into
mainfrom
fix/fractional-rollout-percentages
Aug 18, 2026
Merged

fix: support fractional rollout percentages in local evaluation#699
marandaneto merged 3 commits into
mainfrom
fix/fractional-rollout-percentages

Conversation

@marandaneto

@marandaneto marandaneto commented Aug 17, 2026

Copy link
Copy Markdown
Member

💡 Motivation and Context

Local feature flag definitions can contain fractional condition rollout percentages such as 0.1 or 0.5. The condition model stored this field as an integer, so Gson rejected fractional definitions before they could be evaluated locally.

This changes the internal condition model to store rolloutPercentage as a Double, allowing Gson and the local evaluator to preserve fractional values.

💚 How did you test it?

  • ./gradlew :posthog:test :posthog-server:test using JDK 17
  • make checkFormat
  • make api
  • pnpm changeset status
  • Added local evaluator coverage for 0.1, 0.5, 100.0, 0.0, and null

📝 Checklist

  • I reviewed the submitted code.
  • I added tests to verify the changes.
  • I updated the docs if needed.
  • No breaking change or entry added to the changelog.

If releasing new changes

  • Ran pnpm changeset to generate a changeset file

🤖 Agent context

Autonomy: Human-driven (agent-assisted)

Pi was used to inspect the local-evaluation path, implement the fix, run the test and formatting checks, and perform an isolated autoreview. Autoreview flagged the changed JVM signature, but FlagConditionGroup is annotated @PostHogInternal and is public only for the SDK's multi-module architecture. The human DRI chose the direct Double type instead of adding a compatibility-only integer property to this internal model.

@marandaneto marandaneto self-assigned this Aug 17, 2026
@marandaneto

Copy link
Copy Markdown
Member Author

follow up PostHog/posthog-dotnet#291

@github-actions

github-actions Bot commented Aug 17, 2026

Copy link
Copy Markdown
Contributor

posthog-android Compliance Report

Date: 2026-08-17 07:25:07 UTC
Duration: 118342ms

✅ All Tests Passed!

46/46 tests passed


Capture Tests

29/29 tests passed

View Details
Test Status Duration
Format Validation.Event Has Required Fields 356ms
Format Validation.Event Has Uuid 31ms
Format Validation.Event Has Lib Properties 28ms
Format Validation.Distinct Id Is String 25ms
Format Validation.Token Is Present 23ms
Format Validation.Custom Properties Preserved 26ms
Format Validation.Event Has Timestamp 27ms
Retry Behavior.Retries On 503 7025ms
Retry Behavior.Does Not Retry On 400 4027ms
Retry Behavior.Does Not Retry On 401 4025ms
Retry Behavior.Respects Retry After Header 7025ms
Retry Behavior.Implements Backoff 17036ms
Retry Behavior.Retries On 500 7019ms
Retry Behavior.Retries On 502 7019ms
Retry Behavior.Retries On 504 7017ms
Retry Behavior.Max Retries Respected 17036ms
Deduplication.Generates Unique Uuids 40ms
Deduplication.Preserves Uuid On Retry 7018ms
Deduplication.Preserves Uuid And Timestamp On Retry 12029ms
Deduplication.Preserves Uuid And Timestamp On Batch Retry 7021ms
Deduplication.No Duplicate Events In Batch 37ms
Deduplication.Different Events Have Different Uuids 23ms
Compression.Sends Gzip When Enabled 21ms
Batch Format.Uses Proper Batch Structure 17ms
Batch Format.Flush With No Events Sends Nothing 13ms
Batch Format.Multiple Events Batched Together 31ms
Error Handling.Does Not Retry On 403 4022ms
Error Handling.Does Not Retry On 413 4021ms
Error Handling.Retries On 408 5027ms

Feature_Flags Tests

17/17 tests passed

View Details
Test Status Duration
Request Payload.Request With Person Properties Device Id 34ms
Request Payload.Flags Request Uses V2 Query Param 23ms
Request Payload.Flags Request Hits Flags Path Not Decide 21ms
Request Payload.Flags Request Omits Authorization Header 27ms
Request Payload.Token In Flags Body Matches Init 21ms
Request Payload.Groups Round Trip 31ms
Request Payload.Groups Default To Empty Object 27ms
Request Payload.Disable Geoip False Propagates As Geoip Disable False 23ms
Request Payload.Disable Geoip Omitted Defaults To False 22ms
Request Payload.Flag Keys To Evaluate Contains Only Requested Key 21ms
Request Lifecycle.No Flags Request On Init Alone 10ms
Request Lifecycle.No Flags Request On Normal Capture 24ms
Request Lifecycle.Two Flag Calls Produce Two Remote Requests 42ms
Request Lifecycle.Mock Response Value Is Returned To Caller 19ms
Retry Behavior.Retries Flags On 502 323ms
Retry Behavior.Retries Flags On 504 326ms
Side Effect Events.Get Feature Flag Captures Feature Flag Called Event 23ms

@marandaneto
marandaneto marked this pull request as ready for review August 17, 2026 08:00
@marandaneto
marandaneto requested a review from a team as a code owner August 17, 2026 08:00
@greptile-apps

greptile-apps Bot commented Aug 17, 2026

Copy link
Copy Markdown
Contributor

Reviews (1): Last reviewed commit: "fix: use a double for rollout percentage..." | Re-trigger Greptile

@marandaneto
marandaneto requested a review from a team August 17, 2026 08:03

@arnohillen arnohillen left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(created by claude code)

Verified the only consumer (FlagEvaluator.isConditionMatch) already divides by 100.0 so whole-number behavior is unchanged, Gson reads lossless doubles into Int fields so mixed-version shared-cache fleets stay safe for integral values, and the new test covers the exact fractional failure path; the ABI change is on a @PostHogInternal class with the api dump updated.

@marandaneto
marandaneto merged commit b1c2130 into main Aug 18, 2026
17 checks passed
@marandaneto
marandaneto deleted the fix/fractional-rollout-percentages branch August 18, 2026 06:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants