Skip to content

feat(server): support known-absent property keys in local evaluation - #993

Open
marandaneto wants to merge 26 commits into
mainfrom
feat/flags-known-absent-property-keys
Open

marandaneto wants to merge 26 commits into
mainfrom
feat/flags-known-absent-property-keys

Conversation

@marandaneto

@marandaneto marandaneto commented Nov 19, 2026 •

Copy link
Copy Markdown
Member

💡 Motivation and Context

During local evaluation, the server SDK treats a property key that the caller left out as unknown. A filter on that key can't be decided locally, so the SDK calls /flags instead. A caller has no way to say "this person definitely doesn't have plan". This causes extra remote calls. It also means local results and the /flags fallback could disagree about missing properties.

This PR adds an optional list of property keys the caller knows are absent. It follows the cross-SDK spec in PostHog/sdk-specs#233.

New public input

PostHogEvaluateFlagsOptions, PostHogFeatureFlagOptions and PostHogFeatureFlagResultOptions each get two new optional fields and builder methods:

  • personPropertyKeysKnownAbsent, a list of person property keys.
  • groupPropertyKeysKnownAbsent, a map from group type name to a list of group property keys.

These options already feed evaluateFlags, getFeatureFlag, isFeatureEnabled, getFeatureFlagPayload and getFeatureFlagResult. When nothing is listed, every call behaves exactly as before.

val flags =
    posthog.evaluateFlags(
        "user-1",
        PostHogEvaluateFlagsOptions.builder()
            .personProperty("email", "user@example.com")
            .personPropertyKeysKnownAbsent(listOf("plan"))
            .group("organization", "org-1")
            .groupPropertyKeysKnownAbsent("organization", listOf("tier"))
            .build(),
    )

PostHogCaptureOptions does not get the new fields. To attach flags evaluated with known-absent keys to an event, evaluate a snapshot with these options and pass it to capture.

Local evaluation behavior

  • A filter on a listed key is decided locally with no /flags fallback. is_not_set, is_not, not_icontains, not_starts_with, not_ends_with and not_regex match. is_set and every other supported operator do not match. This includes exact, icontains, regex, the numeric operators, all semver_* operators and the date operators.
  • A listed key counts as absent even when the caller also passed a value for it. It also overrides values the SDK adds itself, such as distinct_id in person properties.
  • A key that is left out and not listed still can't be decided locally, as today.
  • A listed key is resolved from the table without reading the condition value, as the flags service does (docs(flags): resolve known-absent keys without reading the condition value sdk-specs#239). The SDK does not parse, compile or validate a present condition value for it. So not_regex with an invalid or non-portable pattern such as "[" or \p{L} matches, regex with that pattern does not, and gt, semver_* or is_date_* with a malformed operand such as "not-a-number" do not match. Malformed values on a key that is not listed behave as before.
  • Exceptions that stay unresolved with unsupported_definition and fall back to /flags: operators the SDK doesn't support locally (icontains_multi, not_icontains_multi, between, not_between, unknown operators), even when the key is listed, and an omitted or JSON null condition value on an operator that needs one.
  • Operator support is checked before the known-absent table, in flag conditions and in dynamic-cohort leaves, as the latest spec revision requires (docs(flags): specify known-absent property keys sdk-specs#233). FlagEvaluatorTest.testKnownAbsentCohortLeafChecksOperatorSupportBeforeTheTable and PostHogKnownAbsentPropertyKeysTest ("an unsupported operator in a cohort leaf on a listed key falls back before known absence") cover a cohort leaf plan not_between [1, 2] on a listed key, with and without negation, and check that it stays unresolved with unsupported_definition and falls back to /flags.
  • An omitted or JSON null condition value on a listed key stays inconclusive and falls back to /flags, per docs(flags): resolve known-absent keys without reading the condition value sdk-specs#239. is_set and is_not_set keep their known-absent result whatever the value is.
  • Person keys that start with __posthog_person_metadata__ are ignored.
  • Listed keys are scoped by filter type: person keys only resolve person filters, group keys only resolve group filters in a flag aggregated on that same group type, person_metadata filters never resolve from a listing and fall back as before, and a group filter without group_type_index reads the flag's group type and its listed keys. To tell person from person_metadata, core FlagProperty gets an internal rawType field (it is @PostHogInternal) that keeps the wire "type". Broader person_metadata handling is tracked in fix(server): don't match person_metadata filters against person properties #998.
  • In dynamic cohorts, a property on a listed key gets the result above before the cohort's negation is applied. Static cohort membership and holdouts are unchanged.
  • Flag dependencies are evaluated in their own context, and group filters without group_type_index read the condition's group type, per docs(flags): evaluate flag dependencies in their own context sdk-specs#250. A dependency is evaluated exactly as if it were evaluated directly with the same top-level inputs: its own aggregation, properties, listed keys and bucketing identifier (the group key for a group-aggregated dependency). A group-aggregated dependency whose group isn't passed skips its group conditions, like a directly requested flag, so it is false with no fallback unless it has a holdout (see below). This also fixes local results without known-absent keys: before, a dependency always read the parent's identifier and properties.
  • An empty group key counts as no group key, as /flags does (docs(flags): evaluate flag dependencies in their own context sdk-specs#250): each condition aggregated on that group type is skipped, so a flag whose conditions all use it is false locally with no /flags fallback, directly or as a dependency, and a person condition on the same flag still decides. This SDK has no per-condition aggregation_group_type_index (mixed targeting), so every condition of a group flag uses the flag's group type; that gap predates this PR. A null key from a Java caller already behaved this way. The public group maps take String values, so booleans, lists and maps can't be passed.
  • Remote results are cached separately for each set of listed keys. A call with listed keys never reuses a cached result for the same person without them.

/flags request body

When a call with listed keys falls back to /flags, the request body includes person_property_keys_known_absent (a list of strings) and group_property_keys_known_absent (an object from group type to a list of strings). A field is left out when the caller didn't provide it or it is empty. Calls without listed keys send the same body as before.

To support this, PostHogApi.flags in the core posthog module gets a new overload that takes the two lists. The existing flags method keeps its JVM signature, so a posthog-server built against an older core still works. The Android client does not use the new overload.

Over 1000 keys

Each list can hold at most 1000 keys. Duplicates count, and the limit applies to each group type separately. If a list is over the limit, the SDK logs a warning and evaluates nothing. It sends no request and never truncates the list. The call returns its normal "unavailable" result. evaluateFlags returns an empty snapshot. getFeatureFlag, getFeatureFlagPayload and isFeatureEnabled return the default value. getFeatureFlagResult returns null.

A null element in the person list or in any group list (possible from Java callers) is rejected the same way: the SDK logs a warning, evaluates nothing, sends no request and returns the unavailable result.

Not included

💚 How did you test it?

New tests:

  • FlagEvaluatorTest covers the result for every operator on a listed key, an omitted key that isn't listed, unsupported operators and omitted values on a listed key, malformed present values on a listed key that resolve without being read, cohort negation, flag dependencies, the metadata prefix and empty lists, and the 1000-key limit with duplicates.
  • PostHogKnownAbsentPropertyKeysTest runs the full client against MockWebServer. It covers a listed key overriding a supplied value with no /flags call, overriding the distinct_id the SDK adds, group-type scoping, the /flags body with and without listed keys, separate caching for getters, fallback for an unsupported operator, and the over-limit behavior for every entry point.
  • PostHogFlagsRequestTest checks that the body includes the new fields when provided and leaves them out when they are null or empty.

Commands run locally with JDK 17:

  • ./gradlew :posthog:test :posthog-server:test spotlessCheck :posthog:apiCheck :posthog-server:apiCheck passed.
  • After the cohort-leaf tests were added, the new tests passed on their first run with no production change. The same command passed again with 1839 tests and 0 failures.

CI now runs SDK test harness 1.34.0. Its Capture_V1 test request_size.batches_close_before_byte_target failed because the adapter's /capture route ignored pad_properties_to_bytes. The route now pads properties the same way /capture_ai does, and all 243 harness tests passed locally with docker compose in sdk_compliance_adapter. The new non_utc_event_timestamp_is_converted_to_utc test exposed that the adapter ignored the timestamp on /capture, so the adapter now passes it to capture. The known-absent suite doesn't run because the adapter doesn't declare feature_flags_local_evaluation_v1 or feature_flags_known_absent_v1.

Omitted and null condition values on a listed key (PostHog/sdk-specs#239): PostHogKnownAbsentPropertyKeysTest adds "an omitted or null condition value on a listed key stays inconclusive and falls back to flags" (is_not with no value, and is_not, exact and gt with "value": null; each is unresolved with unsupported_definition in local-only mode and falls back to /flags) and "is_set and is_not_set with a null condition value on a listed key keep their known-absent result". Both passed on their first run with no production change. ./gradlew spotlessCheck :posthog:apiCheck :posthog-server:apiCheck :posthog-server:test :posthog:test passed with 2048 tests and 0 failures after merging main.

Resolving a listed key without reading the condition value (PostHog/sdk-specs#239): PostHogKnownAbsentPropertyKeysTest adds "a listed key resolves without reading a present condition value". It covers not_regex and regex with "[" and \p{L}, gt, gte, lt and lte with "not-a-number", semver_gt, semver_eq, semver_tilde, semver_caret and semver_wildcard with "not-a-version", and is_date_before and is_date_after with "not-a-date". Each case runs in local-only mode and through getFeatureFlag, and expects no /flags request. Before the fix, 14 of the 15 cases failed. Only regex "[" already returned false. All 15 pass after the fix. The same file adds "an operator the SDK does not implement on a listed key stays unsupported and falls back to flags" for icontains_multi, not_icontains_multi, between, not_between and an unknown operator. That test passed before and after the fix. FlagEvaluatorTest.testKnownAbsentKeyDoesNotParseAPresentConditionValue replaces the old assertions that malformed values stay unresolved and that an invalid not_regex pattern does not match. It checks each case with negation true and false. ./gradlew :posthog-server:test passed with 712 tests and 0 failures, and spotlessCheck :posthog-server:apiCheck passed.

Type scoping and input check: PostHogKnownAbsentPropertyKeysTest adds "a listed person_metadata key never resolves from the listing" (flag condition and cohort leaf, is_not_set and is_date_before), "a person listing does not resolve a group filter", "a group listing does not resolve a person filter or person cohort leaf on a group flag" and "a flag dependency with a different aggregation does not use the parent's listing" (both directions). All four failed before the fix and pass after it. "a flag dependency with the same aggregation uses the listing" and core PostHogLocalEvaluationModelsTest.testFlagPropertyRawTypeSurvivesASerializerRoundTrip passed before and after as regression tests. "a null key from a Java caller returns the unavailable result without evaluating or sending a request" failed before the fix with an NPE in startsWith and passes after it. ./gradlew spotlessCheck :posthog:apiCheck :posthog-server:apiCheck :posthog:test :posthog-server:test passed with JDK 17 (1340 and 718 tests, 0 failures).

Dependency context and no-index group filters (PostHog/sdk-specs#250), in PostHogKnownAbsentPropertyKeysTest:

  • "a group dependency reads its group's properties, not the person's" (person region=us, group region=eu; the org parent and the person child are both false with no /flags request): red before (the child was true), green after.
  • "a group dependency without its group is false and does not fall back" (no org group, organization listing tier): red before (the child was true), green after.
  • "a group dependency is bucketed on its group key" (50% rollout org parent, 40 orgs, child must follow the parent): red before (org-9 differed), green after.
  • "a person dependency of a group flag reads the person's properties and distinct id" (50% rollout person parent over 40 users): red before (the dependency used the org key and org properties), green after.
  • "a flag dependency with a different aggregation uses the listing for its own aggregation" replaces "a flag dependency with a different aggregation does not use the parent's listing". The old assertions stay, and new ones check that each dependency reads the listing of its own aggregation. Red before, green after.
  • "a group filter without an index reads the flag's group type and its listing" (exact "enterprise" false, is_not_set true with a supplied tier="enterprise"): already green before, kept as a regression test.
  • FlagEvaluatorTest.testFlagDependencyEvaluatesWithTheSameKnownAbsentKeys is renamed to testFlagDependencyReadsTheKnownAbsentKeysOfTheTopLevelContext and now goes through the top-level context.

./gradlew spotlessCheck apiCheck :posthog-server:check :posthog-server-openfeature:check :posthog:test passed with JDK 17 (723 server tests, 0 failures).

Review follow-ups, in PostHogKnownAbsentPropertyKeysTest unless noted:

  • Person keys with the __posthog_person_metadata__ prefix are now sent to /flags unchanged and only ignored in local matching. "remote fallback sends the listed keys and omits them when none were provided" now expects [plan, __posthog_person_metadata__created_at]. It failed before the fix, along with the new test "a listed person-metadata prefixed key is forwarded unchanged but never resolves a person filter locally" and FlagEvaluatorTest.testKnownAbsentPropertyKeysKeepPersonMetadataKeysAndDropEmptyLists. All three pass after it.
  • "a group listing does not resolve a group filter for a different group_type_index" failed before the fix and passes after it. The test uses the reviewer's repro. "a person listing resolves a person filter that carries a group_type_index" also failed until the index check was limited to group filters, and passes now. Core PostHogLocalEvaluationModelsTest.testFlagPropertyRawTypeAndGroupTypeIndexSurviveASerializerRoundTrip checks that the index survives the definitions cache.
  • "a null key or group type from a Java caller returns the unavailable result without evaluating or sending a request" now also covers a map with a null group type. That case failed before the fix and passes after it.
  • "flag getters with listed keys send feature_flag_called from the known-absent cache entry" runs with events on. It checks that the payload getter emits no event, that sendFeatureFlagEvent(false) is respected, the event metadata, and that a failed entry returns the default value without reporting it as the response. This test passed when it was added.

./gradlew spotlessCheck apiCheck :posthog:test :posthog-server:test :posthog-server-openfeature:test :posthog-android:testDebugUnitTest passed with JDK 17.

Group holdout without a key (PostHog/sdk-specs#250): a group flag with a holdout above 0% and no usable group key is now inconclusive with missing_context (falls back to /flags, unresolved in local-only mode) instead of false; PostHogUnusableGroupKeyTest "a group flag with a holdout and an unusable group key is missing context" was red before and passes now, and a 0% holdout or a usable key is unchanged.

Unusable group keys (PostHog/sdk-specs#250): the new PostHogUnusableGroupKeyTest runs each case for "" and a Java null key (direct flag in local-only mode and through the getters, a mixed flag, a group dependency, evaluateFlags and capture(appendFeatureFlags = true) with no /flags call, plus usable-key bucketing and a usable key without properties staying inconclusive). Before the fix, the four unusable-key tests failed on ""; all 6 pass after it, and ./gradlew spotlessCheck :posthog-server:apiCheck :posthog-server:build :posthog-server-openfeature:test passed with JDK 17.

Not run locally: Android instrumented tests and the Compose survey tests.

📝 Checklist

  • All commits are signed (see Commit signing)
  • 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 coding agent (Claude) implemented this from the spec in PostHog/sdk-specs#233 as part of the same change across several SDKs. Before pushing, an automated review ran with a different model, openai-codex/gpt-6.2-astra.

  • Accepted: adding parameters to PostHogApi.flags changed its JVM signature. A posthog-server built against an older core would fail at runtime if only core was upgraded. The old signature now stays, and the new parameters are in a separate overload.
  • Not changed here: the review said a successful local lookup can report $feature_flag_error: unknown_error in $feature_flag_called. A local check showed main already does this for any getter that resolves locally on a cold cache, with no listed keys. The new code path matches the existing behavior. A fix belongs in a separate PR.

The new options are on all three options classes so that the deprecated per-flag getters stay consistent with evaluateFlags.

@marandaneto marandaneto self-assigned this Nov 19, 2026
@github-actions

github-actions Bot commented Nov 19, 2026 •

Copy link
Copy Markdown
Contributor

posthog-android Compliance Report

Date: 2026-11-26T09:21:56.344422+00:00
Duration: 511686ms

✅ All Tests Passed!

243/243 tests passed


Capture_V1 Tests

✅ 111/111 tests passed

View Details
Test Status Duration
Redirects And Library Identity.Follows Same Origin 307 ✅ 2414ms
Redirects And Library Identity.Does Not Follow Cross Origin Redirect ✅ 4031ms
Redirects And Library Identity.Treats 302 As Terminal ✅ 4026ms
Redirects And Library Identity.Follows At Most Five Redirects ✅ 5026ms
Redirects And Library Identity.Sends Lib And Lib Version Per Event ✅ 26ms
Request Size.Batches Close Before Byte Target ✅ 5290ms
Endpoint And Method.Targets V1 Endpoint ✅ 29ms
Endpoint And Method.Does Not Use Legacy Endpoints ✅ 24ms
Required Headers.Has Authorization Bearer Header ✅ 21ms
Required Headers.Has Content Type Json ✅ 24ms
Required Headers.Has Posthog Sdk Info Format ✅ 20ms
Required Headers.Has Posthog Attempt Header ✅ 19ms
Required Headers.Has Posthog Request Id ✅ 22ms
Required Headers.Has Posthog Request Timestamp ✅ 23ms
Required Headers.Has User Agent ✅ 21ms
Body Format.Body Has Created At And Batch ✅ 20ms
Body Format.No Api Key In Body ✅ 21ms
Body Format.No Sent At In Body ✅ 26ms
Event Format.Event Has Required Root Fields ✅ 18ms
Event Format.Event Uuid Is Valid ✅ 27ms
Event Format.Event Timestamp Is Rfc3339 ✅ 24ms
Event Format.Non Utc Event Timestamp Is Converted To Utc ✅ 21ms
Event Format.Distinct Id Is String ✅ 18ms
Event Format.Distinct Id At Root Not Properties ✅ 19ms
Event Format.Custom Properties Preserved ✅ 17ms
Event Format.Set Properties Preserved ✅ 20ms
Event Format.Set Once Properties Preserved ✅ 21ms
Event Format.Groups Properties Preserved ✅ 31ms
Event Format.Sdk Generates Uuid If Not Provided ✅ 20ms
Event Format.Event Has Required Root Fields Batch ✅ 27ms
Event Format.Event Uuid Is Valid Batch ✅ 25ms
Event Format.Event Timestamp Is Rfc3339 Batch ✅ 24ms
Event Format.Distinct Id Is String Batch ✅ 23ms
Event Format.Distinct Id At Root Not Properties Batch ✅ 25ms
Event Format.Custom Properties Preserved Batch ✅ 24ms
Event Format.Set Properties Preserved Batch ✅ 25ms
Event Format.Set Once Properties Preserved Batch ✅ 32ms
Event Format.Groups Properties Preserved Batch ✅ 32ms
Event Format.Sdk Generates Uuid If Not Provided Batch ✅ 25ms
Batch Behavior.Multiple Events In Single Batch ✅ 33ms
Batch Behavior.Batch Envelope Smoke ✅ 28ms
Batch Behavior.Flush With No Events Sends Nothing ✅ 11ms
Batch Behavior.Flush At Triggers Batch ✅ 1016ms
Batch Behavior.Created At Reflects Batch Creation Time ✅ 18ms
Deduplication.Generates Unique Uuids ✅ 37ms
Deduplication.Different Events Same Content Different Uuids ✅ 22ms
Deduplication.Preserves Uuid On Retry ✅ 7013ms
Deduplication.Preserves Timestamp On Retry ✅ 7019ms
Deduplication.Preserves Uuid And Timestamp On Batch Retry ✅ 7016ms
Deduplication.No Duplicate Events In Batch ✅ 30ms
Header Behavior On Retry.Attempt Header Starts At One ✅ 17ms
Header Behavior On Retry.Attempt Header Increments On Retry ✅ 12024ms
Header Behavior On Retry.Request Id Preserved On Retry ✅ 7017ms
Header Behavior On Retry.Different Requests Have Different Request Ids ✅ 2030ms
Header Behavior On Retry.Request Timestamp Changes On Retry ✅ 7015ms
Response Format Validation.Success Response Has Uuid Keyed Results ✅ 16ms
Response Format Validation.Success Response Has Ok For Each Event ✅ 21ms
Response Format Validation.Success No Retry After When All Ok ✅ 17ms
Response Format Validation.Success Retry After Present When Retry Events ✅ 2010ms
Response Format Validation.Success No Retry After When Drop Only ✅ 17ms
Response Format Validation.Response Echoes Request Id ✅ 14ms
Retry Behavior.Retries On 408 ✅ 7012ms
Retry Behavior.Retries On 500 ✅ 7016ms
Retry Behavior.Retries On 503 ✅ 7021ms
Retry Behavior.Retries On 504 ✅ 7012ms
Retry Behavior.Retries On 404 ✅ 7012ms
Retry Behavior.Retries On 429 ✅ 6014ms
Retry Behavior.Retries On 502 ✅ 7015ms
Retry Behavior.Retryable Errors Have Retry After ✅ 4015ms
Retry Behavior.Respects Retry After On Retryable Error ✅ 10026ms
Retry Behavior.Does Not Retry On 400 ✅ 4017ms
Retry Behavior.Does Not Retry On 401 ✅ 4019ms
Retry Behavior.Does Not Retry On 402 ✅ 4016ms
Retry Behavior.Does Not Retry On 413 ✅ 4021ms
Retry Behavior.Does Not Retry On 415 ✅ 4019ms
Retry Behavior.Non Retryable Errors Have No Retry After ✅ 4019ms
Retry Behavior.Implements Backoff ✅ 14031ms
Partial Batch Handling.Handles 200 Full Success ✅ 2017ms
Partial Batch Handling.Handles 200 With All Ok ✅ 3026ms
Partial Batch Handling.Does Not Retry Dropped Events ✅ 3022ms
Partial Batch Handling.Does Not Retry Warning Events ✅ 3021ms
Partial Batch Handling.Prunes Ok Events On Partial Retry ✅ 7015ms
Partial Batch Handling.Prunes Dropped Events On Partial Retry ✅ 7017ms
Partial Batch Handling.Retries Only Retry Events From Partial ✅ 7011ms
Partial Batch Handling.Partial Retry Preserves Uuids ✅ 7018ms
Partial Batch Handling.Partial Retry Attempt Header Increments ✅ 7016ms
Partial Batch Handling.Partial Retry Request Id Preserved ✅ 7013ms
Partial Batch Handling.Respects Retry After On Partial ✅ 7021ms
Partial Batch Handling.Unknown Result Treated As Terminal ✅ 3021ms
Partial Batch Handling.Mixed Ok Drop Warning No Retry ✅ 3026ms
Compression.Sends Gzip Content Encoding ✅ 17ms
Compression.No Content Encoding When Disabled ✅ 14ms
Compression.Compressed Body Is Decompressible ✅ 14ms
Error Handling.Does Not Retry On Unknown 4Xx ✅ 4016ms
Event Options.Cookieless Mode Override ✅ 15ms
Event Options.Disable Skew Correction Override ✅ 14ms
Event Options.Process Person Profile Override ✅ 12ms
Event Options.Product Tour Id Override ✅ 15ms
Event Options.Unset Options Omitted ✅ 15ms
Event Options.Options Override In Batch ✅ 21ms
Event Options.Unknown Option Passes Through ✅ 15ms
Event Options.Option Value Is Not Converted ✅ 16ms
Event Options.Lenient Bool Option Values Are Not Converted ✅ 14ms
Event Options.Option Wins Over Legacy Property ✅ 15ms
Event Options.Legacy Property Fills Unset Option ✅ 13ms
Event Options.Null Option Falls Back To Legacy Property ✅ 14ms
Property Layers.Caller Property Beats Registered Property ✅ 14ms
Property Layers.Before Send Runs Last ✅ 14ms
Fail Open.Empty Api Key Sends Nothing ✅ 3012ms
Fail Open.Personal Api Key Sends Nothing ✅ 3011ms
Geoip And Historical Migration.Historical Migration Absent By Default ✅ 15ms

Capture_Ai_V1 Tests

✅ 115/115 tests passed

View Details
Test Status Duration
Redirects And Library Identity.Follows Same Origin 307 ✅ 2021ms
Redirects And Library Identity.Does Not Follow Cross Origin Redirect ✅ 4018ms
Redirects And Library Identity.Treats 302 As Terminal ✅ 4016ms
Redirects And Library Identity.Follows At Most Five Redirects ✅ 5017ms
Redirects And Library Identity.Sends Lib And Lib Version Per Event ✅ 15ms
Endpoint And Method.Targets V1 Endpoint ✅ 13ms
Endpoint And Method.Does Not Use Legacy Endpoints ✅ 12ms
Endpoint And Method.Capture Does Not Reroute Ai Named Events ✅ 12ms
Endpoint And Method.Capture Ai Does Not Reroute Non Ai Events ✅ 17ms
Lane Isolation.Failing Ai Lane Does Not Delay Analytics ✅ 7023ms
Required Headers.Has Authorization Bearer Header ✅ 15ms
Required Headers.Has Content Type Json ✅ 12ms
Required Headers.Has Posthog Sdk Info Format ✅ 14ms
Required Headers.Has Posthog Attempt Header ✅ 13ms
Required Headers.Has Posthog Request Id ✅ 13ms
Required Headers.Has Posthog Request Timestamp ✅ 13ms
Required Headers.Has User Agent ✅ 17ms
Body Format.Body Has Created At And Batch ✅ 14ms
Body Format.No Api Key In Body ✅ 16ms
Body Format.No Sent At In Body ✅ 13ms
Event Format.Event Has Required Root Fields ✅ 13ms
Event Format.Event Uuid Is Valid ✅ 15ms
Event Format.Event Timestamp Is Rfc3339 ✅ 13ms
Event Format.Non Utc Event Timestamp Is Converted To Utc ✅ 15ms
Event Format.Distinct Id Is String ✅ 12ms
Event Format.Distinct Id At Root Not Properties ✅ 15ms
Event Format.Custom Properties Preserved ✅ 15ms
Event Format.Set Properties Preserved ✅ 14ms
Event Format.Set Once Properties Preserved ✅ 16ms
Event Format.Groups Properties Preserved ✅ 14ms
Event Format.Sdk Generates Uuid If Not Provided ✅ 13ms
Event Format.Event Has Required Root Fields Batch ✅ 21ms
Event Format.Event Uuid Is Valid Batch ✅ 19ms
Event Format.Event Timestamp Is Rfc3339 Batch ✅ 17ms
Event Format.Distinct Id Is String Batch ✅ 28ms
Event Format.Distinct Id At Root Not Properties Batch ✅ 19ms
Event Format.Custom Properties Preserved Batch ✅ 19ms
Event Format.Set Properties Preserved Batch ✅ 22ms
Event Format.Set Once Properties Preserved Batch ✅ 18ms
Event Format.Groups Properties Preserved Batch ✅ 18ms
Event Format.Sdk Generates Uuid If Not Provided Batch ✅ 17ms
Batch Behavior.Multiple Events In Single Batch ✅ 21ms
Batch Behavior.Batch Envelope Smoke ✅ 21ms
Batch Behavior.Flush At Triggers Batch ✅ 1015ms
Batch Behavior.Created At Reflects Batch Creation Time ✅ 14ms
Deduplication.Generates Unique Uuids ✅ 29ms
Deduplication.Different Events Same Content Different Uuids ✅ 17ms
Deduplication.Preserves Uuid On Retry ✅ 7011ms
Deduplication.Preserves Timestamp On Retry ✅ 7016ms
Deduplication.Preserves Uuid And Timestamp On Batch Retry ✅ 7016ms
Deduplication.No Duplicate Events In Batch ✅ 23ms
Header Behavior On Retry.Attempt Header Starts At One ✅ 14ms
Header Behavior On Retry.Attempt Header Increments On Retry ✅ 12023ms
Header Behavior On Retry.Request Id Preserved On Retry ✅ 7012ms
Header Behavior On Retry.Different Requests Have Different Request Ids ✅ 2028ms
Header Behavior On Retry.Request Timestamp Changes On Retry ✅ 7015ms
Response Format Validation.Success Response Has Uuid Keyed Results ✅ 14ms
Response Format Validation.Success Response Has Ok For Each Event ✅ 17ms
Response Format Validation.Success No Retry After When All Ok ✅ 16ms
Response Format Validation.Success Retry After Present When Retry Events ✅ 2008ms
Response Format Validation.Success No Retry After When Drop Only ✅ 17ms
Response Format Validation.Response Echoes Request Id ✅ 12ms
Retry Behavior.Retries On 408 ✅ 7013ms
Retry Behavior.Retries On 500 ✅ 7014ms
Retry Behavior.Retries On 503 ✅ 7020ms
Retry Behavior.Retries On 504 ✅ 7015ms
Retry Behavior.Retries On 404 ✅ 7015ms
Retry Behavior.Retries On 429 ✅ 6014ms
Retry Behavior.Retries On 502 ✅ 7015ms
Retry Behavior.Retryable Errors Have Retry After ✅ 4014ms
Retry Behavior.Respects Retry After On Retryable Error ✅ 10023ms
Retry Behavior.Does Not Retry On 400 ✅ 4017ms
Retry Behavior.Does Not Retry On 401 ✅ 4016ms
Retry Behavior.Does Not Retry On 402 ✅ 4020ms
Retry Behavior.Does Not Retry On 413 ✅ 4016ms
Retry Behavior.Does Not Retry On 415 ✅ 4016ms
Retry Behavior.Non Retryable Errors Have No Retry After ✅ 4016ms
Retry Behavior.Implements Backoff ✅ 14027ms
Partial Batch Handling.Handles 200 Full Success ✅ 2015ms
Partial Batch Handling.Handles 200 With All Ok ✅ 3023ms
Partial Batch Handling.Does Not Retry Dropped Events ✅ 3019ms
Partial Batch Handling.Does Not Retry Warning Events ✅ 3021ms
Partial Batch Handling.Prunes Ok Events On Partial Retry ✅ 7013ms
Partial Batch Handling.Prunes Dropped Events On Partial Retry ✅ 7016ms
Partial Batch Handling.Retries Only Retry Events From Partial ✅ 7014ms
Partial Batch Handling.Partial Retry Preserves Uuids ✅ 7014ms
Partial Batch Handling.Partial Retry Attempt Header Increments ✅ 7016ms
Partial Batch Handling.Partial Retry Request Id Preserved ✅ 7015ms
Partial Batch Handling.Respects Retry After On Partial ✅ 7020ms
Partial Batch Handling.Unknown Result Treated As Terminal ✅ 3020ms
Partial Batch Handling.Mixed Ok Drop Warning No Retry ✅ 3023ms
Compression.Sends Gzip Content Encoding ✅ 15ms
Compression.No Content Encoding When Disabled ✅ 13ms
Compression.Compressed Body Is Decompressible ✅ 13ms
Error Handling.Does Not Retry On Unknown 4Xx ✅ 4014ms
Event Options.Cookieless Mode Override ✅ 13ms
Event Options.Disable Skew Correction Override ✅ 12ms
Event Options.Process Person Profile Override ✅ 11ms
Event Options.Product Tour Id Override ✅ 12ms
Event Options.Unset Options Omitted ✅ 11ms
Event Options.Options Override In Batch ✅ 16ms
Event Options.Unknown Option Passes Through ✅ 10ms
Event Options.Option Value Is Not Converted ✅ 11ms
Event Options.Lenient Bool Option Values Are Not Converted ✅ 13ms
Event Options.Option Wins Over Legacy Property ✅ 14ms
Event Options.Legacy Property Fills Unset Option ✅ 17ms
Event Options.Null Option Falls Back To Legacy Property ✅ 15ms
Event Size.Event Over Ceiling Is Not Sent ✅ 3226ms
Event Size.Over Ceiling Drop Is Reported Or Logged Without Content ✅ 2047ms
Event Size.Batches Close Before Byte Target ✅ 6068ms
Geoip And Historical Migration.Historical Migration Absent By Default ✅ 15ms
Property Layers.Caller Property Beats Registered Property ✅ 13ms
Property Layers.Before Send Runs Last ✅ 14ms
Fail Open.Empty Api Key Sends Nothing ✅ 1010ms
Fail Open.Personal Api Key Sends Nothing ✅ 1008ms

Feature_Flags Tests

✅ 17/17 tests passed

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

@marandaneto
marandaneto marked this pull request as ready for review November 20, 2026 10:28
@marandaneto
marandaneto requested a review from a team as a code owner November 20, 2026 10:28
@veria-ai

veria-ai Bot commented Nov 20, 2026 •

Copy link
Copy Markdown

PR overview

No security issues were found in this pull request.

Reviews

@dustinbyrne dustinbyrne 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.

The /flags wire format, 1000-key validation cap, known-absent operator table, FeatureFlagCacheKey isolation, and binary-compatible PostHogApi.flags overload look solid. Before approval, there are a few items to address inline:

  • Local evaluation scoping (Breaking): computeFlagLocally threads one knownAbsentKeys set across person_metadata (created_at), dynamic cohorts inside group flags, and cross-aggregation flag dependencies, turning safe /flags fallback into wrong local results.
  • Java null collection elements (Concern): Arrays.asList("plan", null) crashes evaluateFlags with an unhandled NullPointerException, and groupPropertyKeysKnownAbsent serializes null into /flags, which the backend rejects with HTTP 400.
  • Test coverage (Concern): the newly added sendFeatureFlagCalledWithKnownAbsent, failed guard, and valid getFeatureFlagPayload paths in PostHog.kt are currently unexecuted by tests.
  • Spec/backend alignment (Question) and minor KDoc/rebase suggestions inline.

Also note that this branch currently has merge conflicts with main (after posthog-android 4.0 / posthog 7.0 landed) across .github/workflows/sdk-compliance-tests.yml, sdk_compliance_adapter/docker-compose.yml, sdk_compliance_adapter/src/main/kotlin/com/posthog/compliance/ComplianceAdapter.kt, and posthog/api/posthog.api.

Follow-ups (outside this PR):

  • PostHog/posthog.com (Client Libraries / Docs): update contents/docs/feature-flags/local-evaluation/index.mdx (which still states is_not_set cannot evaluate locally) and contents/docs/libraries/java/index.mdx once this ships.
  • PostHog/posthog (Feature Flags): rust/feature-flags/src/properties/property_matching.rs (OperatorType::NotRegex) returns true for a missing/known-absent key before checking regex validity, which diverges from PostHog/sdk-specs#233's false rule.

AI-assisted review.

Comment thread .changeset/quiet-keys-absent.md Resolved
@dustinbyrne
dustinbyrne requested a review from a team November 23, 2026 19:15

@dustinbyrne dustinbyrne 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.

The follow-up commits cleanly resolved the merge conflicts (ff3d0585/0da519fc), the sdk-specs#233/#239 value-parsing alignment (8c6857fe/43de3307), the person_metadata/cohort/cross-aggregation scoping (dd964eb1), and Java null list elements (260c7902). Before approval, a few items remain:

Follow-ups (outside this PR):

  • PostHog/posthog.com (Client Libraries / Docs): update contents/docs/feature-flags/local-evaluation/index.mdx and contents/docs/libraries/java/index.mdx once released.
  • Client Libraries: opt sdk_compliance_adapter into feature_flags_local_evaluation_v1 / feature_flags_known_absent_v1 when ready to run the shared known-absent harness suite in CI.

AI-assisted review.

@dustinbyrne
dustinbyrne requested a review from a team November 24, 2026 14:42
…nt-property-keys

# Conflicts:
#	.github/workflows/sdk-compliance-tests.yml
…nt-property-keys

# Conflicts:
#	posthog-server/src/main/java/com/posthog/server/internal/FlagEvaluator.kt

@ioannisj ioannisj 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.

🤖 An AI agent wrote this on behalf of @ioannisj.

No findings. I went through the known-absent handling in local evaluation, the per-listing cache keys, the /flags fallback body and the 1000-key limit against PostHog/sdk-specs#233, plus the newer commits: group_type_index scoping for group keys, the __posthog_person_metadata__ keys forwarded to /flags, the null group type guard, dependencies evaluated in their own context, and empty group keys counting as no group. It all lines up with the spec and posthog-js.

…nt-property-keys

# Conflicts:
#	posthog-server/src/main/java/com/posthog/server/internal/FlagEvaluator.kt
#	posthog-server/src/main/java/com/posthog/server/internal/PostHogFeatureFlags.kt
This SDK has no per-condition aggregation, so every condition of a group
flag reads the flag-level group and the flag-level false for a missing or
empty group key stays correct. Tests cover the mixed flag (person condition
decides) and the pure group flag (false, no /flags request).

Holdout: a group flag with a holdout above 0% and no usable group key is
now inconclusive with missing_context, checked before the flag-level false.
The flags service buckets the holdout on the missing key, which can't be
reproduced locally. Only holdout.exclusion_percentage is parsed; a missing
or malformed holdout counts as none.

This branch has not been deployed

No deployments
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