fix: align durable queue retries with SDK specs - #134
Conversation
posthog-unity Compliance ReportDate: 2026-09-04 20:05:44 UTC ✅ All Tests Passed!46/46 tests passed Capture Tests✅ 29/29 tests passed View Details
Feature_Flags Tests✅ 17/17 tests passed View Details
|
303a0c1 to
d5498e0
Compare
Prompt To Fix All With AI### Issue 1
tests/PostHog.Unity.Tests/EventQueueTests.cs:107-118
**Retry flow coverage is incomplete**
These tests stop after the first failed request and only confirm that the record stays queued. The replay tests at `tests/PostHog.Unity.Tests/ReplayQueueTests.cs:61-77` do the same. They do not advance through multiple retries to a successful delivery or verify that retry state resets. This violates the repository directive requiring comprehensive tests of the complete retry flow with multiple attempts, so the requirement must be satisfied before merging.
---
For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.Reviews (1): Last reviewed commit: "refactor: defer retry-after handling to ..." | Re-trigger Greptile |
| public void RetryableFailuresRetainEntries(int statusCode) | ||
| { | ||
| var harness = CreateHarness(); | ||
| harness.Queue.Enqueue(Event("retained")); | ||
| var id = Assert.Single(harness.Storage.GetEventIds()); | ||
| harness.Results.Enqueue((false, statusCode)); | ||
|
|
||
| RunCoroutine(harness.Queue.FlushCoroutine()); | ||
|
|
||
| Assert.Equal(id, Assert.Single(harness.Storage.GetEventIds())); | ||
| Assert.Single(harness.Attempts); | ||
| } |
There was a problem hiding this comment.
Retry flow coverage is incomplete
These tests stop after the first failed request and only confirm that the record stays queued. The replay tests at tests/PostHog.Unity.Tests/ReplayQueueTests.cs:61-77 do the same. They do not advance through multiple retries to a successful delivery or verify that retry state resets. This violates the repository directive requiring comprehensive tests of the complete retry flow with multiple attempts, so the requirement must be satisfied before merging.
Rule Used: When implementing retry logic, include comprehensi... (source)
Learned From
PostHog/posthog#32651
Knowledge Base Used: SDK validation and release automation
Prompt To Fix With AI
This is a comment left during a code review.
Path: tests/PostHog.Unity.Tests/EventQueueTests.cs
Line: 107-118
Comment:
**Retry flow coverage is incomplete**
These tests stop after the first failed request and only confirm that the record stays queued. The replay tests at `tests/PostHog.Unity.Tests/ReplayQueueTests.cs:61-77` do the same. They do not advance through multiple retries to a successful delivery or verify that retry state resets. This violates the repository directive requiring comprehensive tests of the complete retry flow with multiple attempts, so the requirement must be satisfied before merging.
**Rule Used:** When implementing retry logic, include comprehensi... ([source](https://app.greptile.com/posthog-org-19734/-/custom-context?memory=24d1be3f-07fb-465d-b1a7-60dff301aed8))
**Learned From**
[PostHog/posthog#32651](https://github.com/PostHog/posthog/pull/32651)
**Knowledge Base Used:** [SDK validation and release automation](https://app.greptile.com/posthog-org-19734/-/custom-context/knowledge-base/posthog/posthog-unity/-/docs/sdk-validation-and-release.md)
---
For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.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!
💡 Motivation and Context
Unity's analytics and session replay queues can currently delete events after retryable HTTP
408and429responses. Queue entries can also be acknowledged incorrectly when replay capacity changes during an in-flight request, while oversized singleton payloads can block later records indefinitely.This aligns Unity with the durable retry-queue contract in PostHog/sdk-specs#53, alongside PostHog/posthog-ios#788 and PostHog/posthog-android#740.
Changes
408,429, and5xxresponses while preserving terminal endpoint classifications.MaxQueueSizeis lowered.413and remove only a singleton record that remains oversized.The change adds no public API or configuration, and does not change defaults, event payloads, endpoints, or persisted storage layout. Existing payload-UUID storage keys and new queue-owned keys remain mutually readable across upgrades and downgrades. Session replay remains in memory.
💚 How did you test it?
DOTNET_ROOT=/opt/homebrew/opt/dotnet/libexec bin/fmt --checkbin/test— 477 passed, 2 skipped, 0 failedbin/build— netstandard2.1 build, 0 warnings and 0 errorsgit diff --check📝 Checklist
If releasing new changes
pnpm changesetto generate a changeset file (a patch changeset was added directly)🤖 Agent context
Autonomy: Human-driven (agent-assisted)
Implemented with the Pi coding agent in a local session; no public session link is available. The human directed alignment with the shared durable retry-queue contract and requested this draft PR. Fresh SDK-focused reviewer passes checked retry classification, queue identity, capacity, lifecycle behavior, compatibility, and regression coverage. The implementation preserves Unity's existing public surface, payloads, storage layout, defaults, and capped linear backoff.