fix: require Okio 3.11.0 to prevent gzip corruption - #831
dustinbyrne wants to merge 3 commits into
Conversation
|
[High risk] Upgrades a core compression dependency across all modules. The PR appears safe to merge; no new actionable issue was identified. Reviews (2) · Last reviewed commit: "chore: include surveys compose in Okio f..." |
posthog-android Compliance ReportDate: 2026-10-02 17:15:00 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
|
|
One compatibility note: this can break Kotlin 1.9 projects that currently work by overriding the Kotlin standard library, if Okio is exposed on their compile classpath. Okio 3.11.0 carries Kotlin 2.1 metadata, which the 1.9 compiler cannot read. Our existing configured compatibility target is already Kotlin 2.0: kotlinVersion=2.1.21
kotlinCompatibility=2.0These settings predate this PR: The bump therefore preserves the configured Kotlin 2.0 target, but not every previously working Kotlin 1.9 override configuration. A Kotlin 2.0.0 Android consumer of this branch’s published artifact passed compilation and an R8-minified release build. |
|
Should we bump min. Okhttp then that depends on okio min 3.11? This could cause incompatibilities i think, okio is a transitive dep |
|
i believe it's okay
|
| # This file is expected to be part of source control. | ||
| # To regenerate this file, run: ./gradlew :posthog-android:dependencies --write-locks | ||
| androidx.activity:activity-compose:1.13.0=debugUnitTestCompileClasspath,debugUnitTestRuntimeClasspath,releaseUnitTestCompileClasspath,releaseUnitTestRuntimeClasspath | ||
| androidx.activity:activity-compose:1.13.0=debugUnitTestCompileClasspath,debugUnitTestRuntimeClasspath,releaseUnitTestCompileClasspath,releaseUnitTestRuntimeClasspath,testImplementationDependenciesMetadata |
There was a problem hiding this comment.
[question] Most of the churn in this file is testImplementationDependenciesMetadata moving between entries, which doesn't look Okio-related. Was it from regenerating locks in a different setup, or expected?
💡 Motivation and Context
Require Okio 3.11.0 or later so gzip request compression includes the fix for Okio #1608.
Older Okio versions can recycle a compression input buffer while
Deflaterstill retains its reference. When Android's JNI layer copies arrays, a later flush can overwrite compressed output with stale input. This can produce invalid/flagsand/batchrequest bodies before transmission. Okio 3.11.0 clears the retained reference.Compatibility
The Kotlin language/API compatibility target remains 2.0, and the Java bytecode target remains Java 8. A Kotlin 2.0.0 Android consumer of the locally published artifact builds successfully, including a minified release APK.
Okio 3.11.0 contains Kotlin 2.1 metadata. Kotlin 1.9 projects that currently work by overriding the standard library can fail if Okio appears on their compile classpath. Current PostHog already resolves Kotlin stdlib 2.1.21; this does not raise the configured Kotlin 2.0 floor, but those older override configurations are not compatibility-neutral.
💚 How did you test it?
./gradlew :posthog:test --tests com.posthog.internal.GzipRequestInterceptorTest --tests com.posthog.internal.PostHogApiTestbuildplus:posthog-android-gradle-plugin:build; final pass excluded the sample's mapping-upload task.make checkFormatmake checkReleasewith an isolated local Maven repository; committed locks remain unchanged.installDistwith its normally Docker-included project enabled through a temporary init script.requires: 3.11.0) and Maven runtime dependency (okio-jvm:3.11.0).Prior controlled Android 16 reproduction used
app_process -Xcheck:jni -Xjniopts:forcecopy: with core 6.43.0, Okio 3.9.1 failed all 80 flags/batch compression checks per run, while 3.11.0 passed. Three runs per version agreed. Java gzip controls passed. This demonstrates the upstream mechanism; it does not establish why a particular managed device triggers equivalent behavior. The checked-in JVM test is round-trip coverage, not a forced-JNI reproduction.📝 Checklist
If releasing new changes
pnpm changesetto generate a changeset file🤖 Agent context
Autonomy: Human-driven (agent-assisted)
Implemented with Pi using local Gradle/Android builds and GitHub CLI. A fresh read-only reviewer inspected the diff and found no issues. Human review is required before merge.