fix: recompress request bodies on retry - #184
Merged
Merged
Conversation
Member
Author
|
detected by compliance tests |
Contributor
posthog-elixir Compliance ReportDate: 2026-08-12 07:19:37 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
|
Prompt To Fix All With AI### Issue 1
test/posthog/api/client_test.exs:68
**Retry test stops too early**
Setting `max_retries` to 1 verifies only the initial request and first retry, leaving compression-state regressions on later retries undetected.
```suggestion
max_retries: 2,
```
---
For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.Reviews (1): Last reviewed commit: "fix: recompress request bodies on retry" | Re-trigger Greptile |
dustinbyrne
approved these changes
Aug 12, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
💡 Motivation and Context
Req re-encodes JSON request bodies when retrying, but retains the
content-encoding: gzipheader from the previous attempt. The retry body is therefore sent as plain JSON while marked as gzip. This caused retry requests to be unreadable and made six SDK compliance tests fail.This change removes the stale content encoding before the compression step runs again. The retry is sent with a valid gzip body that preserves the original event UUID and timestamp. Compression fallback also removes the gzip header before sending an uncompressed body.
💚 How did you test it?
mix format --check-formattedmix test- 331 passed, 18 excludedmix credo --strictmix test test/posthog/api/client_test.exs- 17 passeddocker compose up --build --abort-on-container-exit --exit-code-from test-harnessinsdk_compliance_adapter- 46/46 compliance tests passed📝 Checklist
If releasing new changes
sampo addto generate a changeset file🤖 Agent context
Autonomy: Human-driven (agent-assisted)
Pi was used to reproduce the compliance failures, inspect Req's retry pipeline, implement the fix, and run the project and Docker compliance suites. Autoreview checked the final committed diff and found no actionable issues. GitHub CLI was used to create this pull request.