Skip to content

fix: Clear feature flag called cache on shutdown#694

Merged
marandaneto merged 1 commit into
mainfrom
fix/ff-called-cache-shutdown
Jun 24, 2026
Merged

fix: Clear feature flag called cache on shutdown#694
marandaneto merged 1 commit into
mainfrom
fix/ff-called-cache-shutdown

Conversation

@marandaneto

Copy link
Copy Markdown
Member

💡 Motivation and Context

Shutting down a Client did not reset the in-memory feature flag $feature_flag_called dedupe cache, so a reused client instance could keep stale per-distinct-id feature flag reporting state after shutdown.

💚 How did you test it?

  • uv run pytest posthog/test/test_client.py::TestClient::test_shutdown_clears_feature_flag_called_dedupe_cache --verbose --timeout=30
  • uv run pytest posthog/test/test_client.py -k shutdown --verbose --timeout=30
  • uv run python -W error -c "import posthog"

📝 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 sampo add to generate a changeset file

🤖 Agent context

Autonomy: Human-driven (agent-assisted)

A coding agent prepared this PR from the existing fix/ff-called-cache-shutdown worktree. The change clears the feature flag called dedupe cache during shutdown, adds a focused regression test, and includes a Sampo patch changeset for release automation.

@marandaneto marandaneto self-assigned this Jun 24, 2026
@greptile-apps

greptile-apps Bot commented Jun 24, 2026

Copy link
Copy Markdown
Contributor

Reviews (1): Last reviewed commit: "fix: clear feature flag called cache on ..." | Re-trigger Greptile

@marandaneto marandaneto marked this pull request as ready for review June 24, 2026 17:25
@marandaneto marandaneto requested a review from a team as a code owner June 24, 2026 17:25
@github-actions

Copy link
Copy Markdown
Contributor

posthog-python Compliance Report

Date: 2026-06-24 17:26:10 UTC
Duration: 530126ms

✅ All Tests Passed!

45/45 tests passed


Capture Tests

29/29 tests passed

View Details
Test Status Duration
Format Validation.Event Has Required Fields 518ms
Format Validation.Event Has Uuid 10007ms
Format Validation.Event Has Lib Properties 10014ms
Format Validation.Distinct Id Is String 10006ms
Format Validation.Token Is Present 10007ms
Format Validation.Custom Properties Preserved 10007ms
Format Validation.Event Has Timestamp 10007ms
Retry Behavior.Retries On 503 18014ms
Retry Behavior.Does Not Retry On 400 12008ms
Retry Behavior.Does Not Retry On 401 10007ms
Retry Behavior.Respects Retry After Header 16013ms
Retry Behavior.Implements Backoff 30018ms
Retry Behavior.Retries On 500 13010ms
Retry Behavior.Retries On 502 16010ms
Retry Behavior.Retries On 504 16011ms
Retry Behavior.Max Retries Respected 30006ms
Deduplication.Generates Unique Uuids 7013ms
Deduplication.Preserves Uuid On Retry 16016ms
Deduplication.Preserves Uuid And Timestamp On Retry 23020ms
Deduplication.Preserves Uuid And Timestamp On Batch Retry 16006ms
Deduplication.No Duplicate Events In Batch 10002ms
Deduplication.Different Events Have Different Uuids 10007ms
Compression.Sends Gzip When Enabled 10007ms
Batch Format.Uses Proper Batch Structure 10007ms
Batch Format.Flush With No Events Sends Nothing 5005ms
Batch Format.Multiple Events Batched Together 10006ms
Error Handling.Does Not Retry On 403 12009ms
Error Handling.Does Not Retry On 413 10007ms
Error Handling.Retries On 408 14013ms

Feature_Flags Tests

16/16 tests passed

View Details
Test Status Duration
Request Payload.Request With Person Properties Device Id 9502ms
Request Payload.Flags Request Uses V2 Query Param 10007ms
Request Payload.Flags Request Hits Flags Path Not Decide 10007ms
Request Payload.Flags Request Omits Authorization Header 10006ms
Request Payload.Token In Flags Body Matches Init 10007ms
Request Payload.Groups Round Trip 10007ms
Request Payload.Groups Default To Empty Object 10007ms
Request Payload.Person Properties Distinct Id Auto Populated When Caller Omits It 10006ms
Request Payload.Disable Geoip False Propagates As Geoip Disable False 10007ms
Request Payload.Disable Geoip Omitted Defaults To False 10007ms
Request Payload.Flag Keys To Evaluate Contains Only Requested Key 10006ms
Request Lifecycle.No Flags Request On Init Alone 5003ms
Request Lifecycle.No Flags Request On Normal Capture 10508ms
Request Lifecycle.Two Flag Calls Produce Two Remote Requests 9510ms
Request Lifecycle.Mock Response Value Is Returned To Caller 10003ms
Side Effect Events.Get Feature Flag Captures Feature Flag Called Event 10509ms

@marandaneto marandaneto merged commit cdd878c into main Jun 24, 2026
33 checks passed
@marandaneto marandaneto deleted the fix/ff-called-cache-shutdown branch June 24, 2026 18:20
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.

2 participants