Skip to content

chore: stabilize sdk compliance adapter#617

Open
marandaneto wants to merge 1 commit into
mainfrom
chore/sdk-compliance-feature-flags
Open

chore: stabilize sdk compliance adapter#617
marandaneto wants to merge 1 commit into
mainfrom
chore/sdk-compliance-feature-flags

Conversation

@marandaneto
Copy link
Copy Markdown
Member

💡 Motivation and Context

Fix the SDK compliance adapter state handling for the Feature_Flags compliance suite.

Dependency: This needs PostHog/posthog-sdk-test-harness#19 first, because the harness currently asserts /flags auth as token and must accept api_key as the supported alias used by posthog-python.

The adapter could deadlock during test reset because it held SDKState.lock while client.shutdown() flushed pending events through the patched transport, which also records requests under the same lock. Feature flag side-effect events could also be flushed after an adapter action returned, leaking into the next compliance test's mock-server state.

💚 How did you test it?

  • uv run --with flask --with python-dateutil python sdk_compliance_adapter/adapter.py
  • From /Users/marandaneto/Github/posthog-sdk-test-harness with PR Client exit when /batch response return none 200 status code.  #19 changes:
    • uv run posthog-test-harness run --adapter-url http://localhost:18080 --suite feature_flags --output text --concurrency 1
    • Result: 16/16 Feature_Flags tests passed

📝 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

@marandaneto marandaneto requested a review from a team as a code owner May 22, 2026 08:49
@greptile-apps
Copy link
Copy Markdown
Contributor

greptile-apps Bot commented May 22, 2026

Reviews (1): Last reviewed commit: "chore: stabilize sdk compliance adapter" | Re-trigger Greptile

@github-actions
Copy link
Copy Markdown
Contributor

posthog-python Compliance Report

Date: 2026-05-22 08:53:35 UTC
Duration: 176050ms

⚠️ Some Tests Failed

43/45 tests passed, 2 failed


Capture Tests

29/29 tests passed

View Details
Test Status Duration
Format Validation.Event Has Required Fields 516ms
Format Validation.Event Has Uuid 1507ms
Format Validation.Event Has Lib Properties 1506ms
Format Validation.Distinct Id Is String 1506ms
Format Validation.Token Is Present 1506ms
Format Validation.Custom Properties Preserved 1506ms
Format Validation.Event Has Timestamp 1506ms
Retry Behavior.Retries On 503 9518ms
Retry Behavior.Does Not Retry On 400 3505ms
Retry Behavior.Does Not Retry On 401 3506ms
Retry Behavior.Respects Retry After Header 9509ms
Retry Behavior.Implements Backoff 23526ms
Retry Behavior.Retries On 500 7515ms
Retry Behavior.Retries On 502 7509ms
Retry Behavior.Retries On 504 7508ms
Retry Behavior.Max Retries Respected 23532ms
Deduplication.Generates Unique Uuids 1495ms
Deduplication.Preserves Uuid On Retry 7515ms
Deduplication.Preserves Uuid And Timestamp On Retry 14519ms
Deduplication.Preserves Uuid And Timestamp On Batch Retry 7506ms
Deduplication.No Duplicate Events In Batch 1503ms
Deduplication.Different Events Have Different Uuids 1506ms
Compression.Sends Gzip When Enabled 1506ms
Batch Format.Uses Proper Batch Structure 1506ms
Batch Format.Flush With No Events Sends Nothing 1004ms
Batch Format.Multiple Events Batched Together 1506ms
Error Handling.Does Not Retry On 403 3508ms
Error Handling.Does Not Retry On 413 3507ms
Error Handling.Retries On 408 7513ms

Feature_Flags Tests

⚠️ 14/16 tests passed, 2 failed

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

Failures

request_payload.request_with_person_properties_device_id

Field 'token' not found in /flags request body at path 'token'. Available keys: ['distinct_id', 'groups', 'person_properties', 'group_properties', 'geoip_disable', 'device_id', 'flag_keys_to_evaluate', 'sentAt', 'api_key']

request_payload.token_in_flags_body_matches_init

Field 'token' not found in /flags request body at path 'token'. Available keys: ['distinct_id', 'groups', 'person_properties', 'group_properties', 'geoip_disable', 'device_id', 'flag_keys_to_evaluate', 'sentAt', 'api_key']

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.

1 participant