Skip to content

fix(flags): handle null early_exit values - #312

Merged
dustinbyrne merged 2 commits into
mainfrom
fix/nullable-early-exit
Sep 2, 2026
Merged

fix(flags): handle null early_exit values#312
dustinbyrne merged 2 commits into
mainfrom
fix/nullable-early-exit

Conversation

@dustinbyrne

Copy link
Copy Markdown
Contributor

💡 Motivation and Context

Fixes #311.

The /flags/definitions response can contain filters.early_exit: null. The SDK modeled this field as a non-nullable boolean, so System.Text.Json rejected the response before local feature flag evaluation could begin.

This makes the internal field nullable while preserving false as the absent-field default. The evaluator already normalizes null to false, so explicit null values now follow the existing non-early-exit path without changing true, false, or omitted-field behavior.

A patch changeset covers PostHog. There are no public API or default-behavior changes.

💚 How did you test it?

  • Reproduced the issue with a regression case that failed before the fix with JsonException: The JSON value could not be converted to System.Boolean.
  • Extended the existing JSON-backed early-exit test to verify both true and null, including the resulting local evaluation behavior.
  • dotnet restore --locked-mode
  • bin/fmt --check
  • dotnet build --configuration Release --no-restore --nologo (0 warnings, 0 errors)
  • dotnet test --configuration Release --no-build --nologo --framework net8.0
    • UnitTests: 1,141 passed, 2 skipped
    • UnitTests.AspNetCore: 50 passed
    • PostHog.AI.Tests: 19 passed

The .NET Core 3.1 test binary builds successfully, but its tests were not run locally because the x64 .NET Core 3.1 host is not installed in this environment.

📝 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 coding agent (openai-codex/gpt-5.6-sol) traced and reproduced the reported serialization failure, implemented the scoped fix test-first, and ran the Simplify skill. A fresh-context builtin reviewer found no blockers and suggested exercising evaluation after deserialization; the final regression theory covers that path for both true and null.

@dustinbyrne dustinbyrne self-assigned this Sep 2, 2026
@github-actions

github-actions Bot commented Sep 2, 2026

Copy link
Copy Markdown
Contributor

posthog-dotnet Compliance Report

Date: 2026-09-02 14:44:48 UTC
Duration: 4253ms

✅ All Tests Passed!

17/17 tests passed


Feature_Flags Tests

17/17 tests passed

View Details
Test Status Duration
Request Payload.Request With Person Properties Device Id 225ms
Request Payload.Flags Request Uses V2 Query Param 125ms
Request Payload.Flags Request Hits Flags Path Not Decide 110ms
Request Payload.Flags Request Omits Authorization Header 109ms
Request Payload.Token In Flags Body Matches Init 108ms
Request Payload.Groups Round Trip 111ms
Request Payload.Groups Default To Empty Object 109ms
Request Payload.Disable Geoip False Propagates As Geoip Disable False 108ms
Request Payload.Disable Geoip Omitted Defaults To False 109ms
Request Payload.Flag Keys To Evaluate Contains Only Requested Key 108ms
Request Lifecycle.No Flags Request On Init Alone 3ms
Request Lifecycle.No Flags Request On Normal Capture 113ms
Request Lifecycle.Two Flag Calls Produce Two Remote Requests 213ms
Request Lifecycle.Mock Response Value Is Returned To Caller 110ms
Retry Behavior.Retries Flags On 502 1114ms
Retry Behavior.Retries Flags On 504 1111ms
Side Effect Events.Get Feature Flag Captures Feature Flag Called Event 211ms

Comment thread .changeset/pink-items-stick.md
@dustinbyrne
dustinbyrne marked this pull request as ready for review September 2, 2026 14:45
@dustinbyrne
dustinbyrne requested a review from a team as a code owner September 2, 2026 14:45
@greptile-apps

greptile-apps Bot commented Sep 2, 2026

Copy link
Copy Markdown
Contributor

Reviews (1): Last reviewed commit: "chore: add PostHog.AspNetCore changeset" | Re-trigger Greptile

@dustinbyrne
dustinbyrne merged commit bbb8d00 into main Sep 2, 2026
20 checks passed
@dustinbyrne
dustinbyrne deleted the fix/nullable-early-exit branch September 2, 2026 14:48
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.

EarlyExit not being nullable is causing local eval to blowup

2 participants