Skip to content

fix: satisfy SDK compliance harness 0.8.0#200

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

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

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_ruby_compliance (45/45).

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

Copy link
Copy Markdown

posthog-ruby Compliance Report

Date: 2026-06-27 12:40:10 UTC
Duration: 98394ms

✅ All Tests Passed!

45/45 tests passed


Capture Tests

29/29 tests passed

View Details
Test Status Duration
Format Validation.Event Has Required Fields 108ms
Format Validation.Event Has Uuid 106ms
Format Validation.Event Has Lib Properties 107ms
Format Validation.Distinct Id Is String 106ms
Format Validation.Token Is Present 106ms
Format Validation.Custom Properties Preserved 106ms
Format Validation.Event Has Timestamp 106ms
Retry Behavior.Retries On 503 5413ms
Retry Behavior.Does Not Retry On 400 2109ms
Retry Behavior.Does Not Retry On 401 2108ms
Retry Behavior.Respects Retry After Header 8115ms
Retry Behavior.Implements Backoff 15722ms
Retry Behavior.Retries On 500 5213ms
Retry Behavior.Retries On 502 5212ms
Retry Behavior.Retries On 504 5208ms
Retry Behavior.Max Retries Respected 15717ms
Deduplication.Generates Unique Uuids 112ms
Deduplication.Preserves Uuid On Retry 5212ms
Deduplication.Preserves Uuid And Timestamp On Retry 10418ms
Deduplication.Preserves Uuid And Timestamp On Batch Retry 5215ms
Deduplication.No Duplicate Events In Batch 111ms
Deduplication.Different Events Have Different Uuids 107ms
Compression.Sends Gzip When Enabled 106ms
Batch Format.Uses Proper Batch Structure 106ms
Batch Format.Flush With No Events Sends Nothing 5ms
Batch Format.Multiple Events Batched Together 110ms
Error Handling.Does Not Retry On 403 2108ms
Error Handling.Does Not Retry On 413 2108ms
Error Handling.Retries On 408 5212ms

Feature_Flags Tests

16/16 tests passed

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

@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 thread lib/posthog/transport.rb
Comment on lines 173 to 175
# Sends a request for the batch, returns [status_code, body]
def send_request(api_key, batch)
payload = JSON.generate(api_key: api_key, batch: batch)

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.

P1 Stale @last_retry_after can leak into the next batch's first retry delay. When retries are exhausted after a 429 response that carries a Retry-After header, retry_delay_seconds is never called (because retries_remaining > 1 is false) and @last_retry_after retains the header value. On the next call to send, if @http.request raises an exception before the mutex block can overwrite the field, retry_delay_seconds reads the stale header and sleeps for that many seconds — potentially thousands of seconds — instead of using the backoff policy. Clearing the field unconditionally at the start of send_request closes the gap.

Suggested change
# Sends a request for the batch, returns [status_code, body]
def send_request(api_key, batch)
payload = JSON.generate(api_key: api_key, batch: batch)
# Sends a request for the batch, returns [status_code, body]
def send_request(api_key, batch)
@last_retry_after = nil
payload = JSON.generate(api_key: api_key, batch: batch)

Comment thread lib/posthog/transport.rb
Comment on lines +157 to +158
seconds = Float(value, exception: false)
return seconds if seconds&.positive?

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 Retry-After: 0 means "retry immediately", but 0.0.positive? returns false, so the method falls through to the HTTP-date branch, fails to parse "0", and returns nil. That causes the caller to use the backoff policy instead of obeying the header. Using seconds&.>=(0) matches the semantics of the header spec (any non-negative number is a valid delay, including zero).

Suggested change
seconds = Float(value, exception: false)
return seconds if seconds&.positive?
seconds = Float(value, exception: false)
return seconds if seconds&.>=(0)

Comment on lines +37 to +49
it 'passes max_retries to the transport as total attempts' do
queue = Queue.new
worker = described_class.new(queue, 'secret', max_retries: 2)

expect(worker.instance_variable_get(:@transport_options)[:retries]).to eq(3)
end

it 'passes compression to the transport when enabled' do
queue = Queue.new
worker = described_class.new(queue, 'secret', enable_compression: true)

expect(worker.instance_variable_get(:@transport_options)[:gzip]).to eq(true)
end

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 Missing boundary cases and the project's parameterised-test preference. The max_retries: 0 path (documented as "disable retrying") is not exercised, so a regression in the + 1 calculation for the zero case would be invisible. Symmetrically, there is no test that enable_compression: false (or nil) leaves :gzip unset in @transport_options. The two new tests also duplicate the queue = Queue.new / described_class.new setup that could be shared in a single parameterised example group.

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!

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