Skip to content

fix: preserve event timestamps and flag request defaults - #253

Merged
marandaneto merged 4 commits into
mainfrom
fix/local-harness-1.31.1-20261115
Nov 18, 2026
Merged

marandaneto merged 4 commits into
mainfrom
fix/local-harness-1.31.1-20261115

Conversation

@marandaneto

@marandaneto marandaneto commented Nov 15, 2026 •

Copy link
Copy Markdown
Member

💡 Motivation and Context

Event timestamps changed by before_send could reach the wire with a non-UTC offset. The compliance adapter also ignored timestamp overrides. Flag requests omitted empty group objects and the existing backend-effective GeoIP default.

This fixes those paths without adding public API or restoring legacy flag parsing:

  • Normalize valid ISO8601 event timestamp strings after before_send, preserving every fractional digit, including beyond microseconds. Leave timestamp-like properties and invalid/non-string hook values unchanged. Generated timestamps bypass parsing.
  • Send groups: {}, group_properties: {} and geoip_disable: false when omitted. Preserve explicit atom-keyed and string-keyed wire options. This makes existing defaults explicit without changing effective GeoIP behavior.
  • Forward raw adapter timestamps through the existing synchronous before_send hook and clear the override after capture.
  • Update regression tests, adapter docs, and a patch Sampo changeset.
  • Pin the reusable compliance workflow to published harness 1.32.0 at immutable release commit dde638562d33572b5c8ac3a2eafc98b92ffa2261. Update local image examples to 1.32.0 as well.

The timestamp behavior follows the canonical capture and before-send-hook contracts. No divergence is intended in the behavior changed here.

Harness 1.32.0 includes the corrected flag fixtures, with rich v2 flags alongside legacy featureFlags. This SDK still requests /flags?v=2 and requires rich responses. The earlier fixture dependency is resolved by the published release, not a local patched image. The published V1 image digest is sha256:7eb6c62e2241ddd48a2dfb326652e7933cd2fe26e0ffcad98cd385d603b4eb82.

💚 How did you test it?

Fresh checks on 12d1ba8e788b8ca5c7cdcb27dfcbad4f7d0ab383:

mix test
mix test test/posthog_test.exs test/posthog/feature_flags/evaluations_test.exs test/posthog/feature_flags_test.exs test/posthog/open_feature_test.exs
mix format --check-formatted
mix compile --warnings-as-errors
mix posthog.public_api --check
mix credo --strict
(cd sdk_compliance_adapter && PORT=19282 MOCK_PORT=19281 mix test)
(cd sdk_compliance_adapter && mix format --check-formatted lib/sdk_compliance_adapter/router.ex test/router_test.exs)
actionlint .github/workflows/sdk-compliance.yml
git diff --check

Native: 1036 passed, 18 existing integration exclusions. Focused regressions: 242 passed. Adapter: 7 passed. Formatting, compilation, public API snapshot, Credo and workflow lint passed. Local tools were Elixir 1.20.4 / OTP 29. Production-credential integration tests were not run locally.

The authoring test audit retained all changed tests and exact wire assertions. Temporarily running current tests against the pre-fix SDK and router from origin/main reproduced 36 native failures for non-UTC timestamps and absent request defaults, plus two adapter failures for timestamp forwarding and defaults. Restoring the fixes made the same suites pass. Coverage includes UTC, both offset signs, date crossings, nine fractional digits, unchanged properties, malformed/native timestamps, explicit context, string-keyed wire options and override cleanup.

A fresh isolated autoreview covered the full committed branch against origin/main (febb4c67ab9cf8892bcafbe3ce179162d375c98e). Its mandatory TruffleHog scan was clean and it reported no actionable findings.

All 29 hosted checks passed on this head, including all 12 supported Elixir/OTP test combinations, Format, Credo, warnings-as-errors/public API checks, Hex packaging, adapter regressions, compliance, CodeQL, Semgrep, Wiz and PR title validation.

  • CI: success.
  • SDK compliance and adapter tests: success. Hosted adapter tests: 7 tests, 0 failures.
  • Downloaded and inspected the complete compliance artifact from that exact new run: 47/47 passed, including 30/30 capture and 17/17 flags, with no failed or missing cases. Every case name matches the selected inventory in published release dde638562d33572b5c8ac3a2eafc98b92ffa2261.
  • The hosted pull resolved harness 1.32.0 to the expected V1 digest above. The profile remains server V0, gzip, concurrency 1, and capabilities capture_v0 / encoding_gzip. No tests were removed or skipped, and no retry settings changed to make the run pass.

Compliance remains advisory in the reusable workflow. The passing result above comes from the actual complete report and test logs, not just a green workflow status.

📝 Checklist

  • All commits are signed (see Commit signing)
  • 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)

Manoel directed the work. A Codex implementation agent used local files, shell, Git and GitHub CLI. Pi ran the fresh isolated autoreview through its Claude Code provider with reviewer tools disabled and a mandatory secret scan. No MCP tools were used. There is no public session link. Human review is required.

The SDK owns normalization and request defaults. The adapter only forwards raw timestamps through the existing hook. Legacy response parsing remains unchanged. Capabilities and the documented single-sender, timer-based flush limitations remain unchanged.

Related PRs

The fixture corrections are now published in harness 1.32.0. This PR uses that release and its immutable reusable workflow SHA.

@marandaneto marandaneto self-assigned this Nov 15, 2026
@github-actions

github-actions Bot commented Nov 15, 2026 •

Copy link
Copy Markdown
Contributor

posthog-elixir Compliance Report

Date: 2026-11-18T10:16:32.371112+00:00
Duration: 111471ms

✅ All Tests Passed!

47/47 tests passed


Capture Tests

✅ 30/30 tests passed

View Details
Test Status Duration
Format Validation.Event Has Required Fields ✅ 611ms
Format Validation.Event Has Uuid ✅ 611ms
Format Validation.Event Has Lib Properties ✅ 612ms
Format Validation.Distinct Id Is String ✅ 612ms
Format Validation.Token Is Present ✅ 612ms
Format Validation.Custom Properties Preserved ✅ 611ms
Format Validation.Event Has Timestamp ✅ 612ms
Format Validation.Non Utc Event Timestamp Is Converted To Utc ✅ 612ms
Retry Behavior.Retries On 503 ✅ 5613ms
Retry Behavior.Does Not Retry On 400 ✅ 2615ms
Retry Behavior.Does Not Retry On 401 ✅ 2615ms
Retry Behavior.Respects Retry After Header ✅ 5618ms
Retry Behavior.Implements Backoff ✅ 15627ms
Retry Behavior.Retries On 500 ✅ 5618ms
Retry Behavior.Retries On 502 ✅ 5616ms
Retry Behavior.Retries On 504 ✅ 5614ms
Retry Behavior.Max Retries Respected ✅ 15627ms
Deduplication.Generates Unique Uuids ✅ 626ms
Deduplication.Preserves Uuid On Retry ✅ 5617ms
Deduplication.Preserves Uuid And Timestamp On Retry ✅ 10622ms
Deduplication.Preserves Uuid And Timestamp On Batch Retry ✅ 5619ms
Deduplication.No Duplicate Events In Batch ✅ 615ms
Deduplication.Different Events Have Different Uuids ✅ 615ms
Compression.Sends Gzip When Enabled ✅ 611ms
Batch Format.Uses Proper Batch Structure ✅ 611ms
Batch Format.Flush With No Events Sends Nothing ✅ 608ms
Batch Format.Multiple Events Batched Together ✅ 616ms
Error Handling.Does Not Retry On 403 ✅ 2612ms
Error Handling.Does Not Retry On 413 ✅ 2615ms
Error Handling.Retries On 408 ✅ 5616ms

Feature_Flags Tests

✅ 17/17 tests passed

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

@marandaneto
marandaneto marked this pull request as ready for review November 17, 2026 09:39
@marandaneto
marandaneto requested a review from a team as a code owner November 17, 2026 09:39
@veria-ai

veria-ai Bot commented Nov 17, 2026 •

Copy link
Copy Markdown

PR overview

No security issues were found in this pull request.

Reviews

@dustinbyrne dustinbyrne left a comment

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.

The timestamp and canonical-request fixes are well covered, but the new defaults can invalidate previously accepted raw flag requests using legacy group aliases. Consider preserving those request shapes before approval.

AI-assisted review.

Comment thread lib/posthog/feature_flags.ex Resolved
@dustinbyrne
dustinbyrne requested a review from a team November 17, 2026 21:23
@marandaneto
marandaneto enabled auto-merge (squash) November 18, 2026 10:18

@stamphog stamphog Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not approved — this change needs a human reviewer.

Re-adding the stamphog label gives the same result unless the changed files change.

stamphog can't clear this pull request because two gates refused it. The deny-list gate matched the infra/CI-CD category, most likely because of the change to .github/workflows/sdk-compliance.yml (the pinned reusable workflow and harness version). The tier gate classified the change as T2-never: a cross-cutting fix touching 13 files and 490 lines, including lib/posthog.ex, lib/posthog/feature_flags.ex, and the compliance adapter.

The author should ask a human reviewer to look at it. Splitting the workflow and harness pin into its own pull request, separate from the timestamp and flag-request fixes, would also make each piece easier to review.

Gate mechanics and policy version
Gate Result
prerequisites ✓ all clear
deny-list ✗ matches: infra_cicd
every_file_attested ✓ not a bot PR
size ✓ 84L, 5F substantive, 490L/13F incl. docs/generated/snapshots — within ceiling
tier ✗ classified as T2-never: T2-never (490L, 13F, cross-cutting, fix)
stamphog 2.9.1 .stamphog/policy.yml @ unknown · reviewed head 71999b3

@stamphog stamphog Bot removed the stamphog label Nov 18, 2026
@marandaneto
marandaneto disabled auto-merge November 18, 2026 10:24
@marandaneto
marandaneto merged commit e94faf5 into main Nov 18, 2026
31 checks passed
@marandaneto
marandaneto deleted the fix/local-harness-1.31.1-20261115 branch November 18, 2026 10:25
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.

3 participants