Skip to content

fix: satisfy SDK compliance harness 0.8.0#699

Draft
marandaneto wants to merge 1 commit into
mainfrom
sdk-harness-audit-20260627-posthog-python
Draft

fix: satisfy SDK compliance harness 0.8.0#699
marandaneto wants to merge 1 commit into
mainfrom
sdk-harness-audit-20260627-posthog-python

Conversation

@marandaneto

@marandaneto marandaneto commented Jun 27, 2026

Copy link
Copy Markdown
Member

Problem

The SDK compliance workflow and local harness need to use SDK test harness release 0.8.0, with reusable GitHub workflow calls pinned to the release commit SHA instead of a mutable tag/branch. Running the updated harness exposed SDK/adapter compliance gaps in this repository.

Changes

  • Pins the reusable SDK compliance workflow to PostHog/posthog-sdk-test-harness commit be8b8d5a3f94a249659844e94832e874f049c1e4.\n- Uses ghcr.io/posthog/sdk-test-harness:0.8.0 for local Docker harness runs / workflow harness version inputs.\n- Updates SDK compliance adapter and/or SDK behavior needed to pass the 0.8.0 compliance contract.

Tests

  • SDK compliance Docker harness passed locally with project posthog_python_compliance.

@marandaneto marandaneto changed the title chore: add SDK compliance harness 0.8.0 fix: satisfy SDK compliance harness 0.8.0 Jun 27, 2026
@greptile-apps

greptile-apps Bot commented Jun 27, 2026

Copy link
Copy Markdown
Contributor

Reviews (1): Last reviewed commit: "chore: add SDK compliance harness 0.8.0" | Re-trigger Greptile

Comment on lines +88 to +99
def test_flags_request_uses_token_field_for_project_api_key():
mock_response = mock.MagicMock()
mock_response.status_code = 200
mock_response.json.return_value = {"featureFlags": {}}

with mock.patch.object(request_module, "post", return_value=mock_response) as mock_post:
flags(TEST_API_KEY, host="https://test.posthog.com", distinct_id="user_1")

mock_post.assert_called_once()
assert mock_post.call_args.kwargs["api_key_field"] == "token"


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.

P2 Non-parameterised test for a parameterisable case

The team's convention is to prefer parameterised tests. The new test covers one scenario (flags() sending "token"); a natural companion case — that plain post() defaults to "api_key" — is left untested. Expressing both as a @pytest.mark.parametrize block would keep them together, make the contract explicit, and make adding future cases (e.g. a hypothetical batch_post variant) straightforward.

Context Used: Do not attempt to comment on incorrect alphabetica... (source)

Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!

@github-actions

Copy link
Copy Markdown
Contributor

posthog-python Compliance Report

Date: 2026-06-27 12:41:06 UTC
Duration: 176155ms

✅ All Tests Passed!

45/45 tests passed


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 1507ms
Format Validation.Distinct Id Is String 1506ms
Format Validation.Token Is Present 1507ms
Format Validation.Custom Properties Preserved 1507ms
Format Validation.Event Has Timestamp 1506ms
Retry Behavior.Retries On 503 9517ms
Retry Behavior.Does Not Retry On 400 3504ms
Retry Behavior.Does Not Retry On 401 3506ms
Retry Behavior.Respects Retry After Header 9515ms
Retry Behavior.Implements Backoff 23515ms
Retry Behavior.Retries On 500 7511ms
Retry Behavior.Retries On 502 7515ms
Retry Behavior.Retries On 504 7510ms
Retry Behavior.Max Retries Respected 23528ms
Deduplication.Generates Unique Uuids 1495ms
Deduplication.Preserves Uuid On Retry 7515ms
Deduplication.Preserves Uuid And Timestamp On Retry 14514ms
Deduplication.Preserves Uuid And Timestamp On Batch Retry 7508ms
Deduplication.No Duplicate Events In Batch 1507ms
Deduplication.Different Events Have Different Uuids 1506ms
Compression.Sends Gzip When Enabled 1507ms
Batch Format.Uses Proper Batch Structure 1506ms
Batch Format.Flush With No Events Sends Nothing 1005ms
Batch Format.Multiple Events Batched Together 1504ms
Error Handling.Does Not Retry On 403 3507ms
Error Handling.Does Not Retry On 413 3509ms
Error Handling.Retries On 408 7514ms

Feature_Flags Tests

16/16 tests passed

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 1006ms
Request Payload.Groups Round Trip 1005ms
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 1010ms
Request Lifecycle.Mock Response Value Is Returned To Caller 1002ms
Side Effect Events.Get Feature Flag Captures Feature Flag Called Event 1509ms

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