Skip to content

feat: send error tracking stack frames in canonical bottom-up order - #603

Merged
cat-ph merged 1 commit into
mainfrom
cat/canonical-frame-order
Jul 22, 2026
Merged

feat: send error tracking stack frames in canonical bottom-up order#603
cat-ph merged 1 commit into
mainfrom
cat/canonical-frame-order

Conversation

@cat-ph

@cat-ph cat-ph commented Jul 3, 2026

Copy link
Copy Markdown
Contributor

💡 Motivation and Context

Part of cross-SDK error tracking standardization: PostHog/sdk-specs#11.

The canonical wire order for $exception_list[].stacktrace.frames is bottom-up: frames[0] is the outermost/entry point and the last frame is the crash site. Today the shared exception coercer emits Java's native innermost-first order (crash site first), which is the opposite of the canonical convention.

This PR flips the frame order to match the spec.

🔧 The change

ThrowableCoercer.fromThrowableToPostHogProperties now walks throwable.stackTrace in reverse when building the frames list, so the emitted order is entry-point-first / crash-site-last.

The $exception_list ordering itself is unchanged (already canonical: [0] = outermost exception, built by walking .cause). Only the per-exception frame order flips.

Because this coercer is shared, the change covers both shipped $libs:

  • posthog-android (Android SDK)
  • posthog-server (Java server SDK)

💚 How did you test it?

  • Updated the existing frame-order assertions in posthog/src/test/java/com/posthog/PostHogTest.kt.
  • Added explicit regression assertions: the emitted frames are the reverse of the native stackTrace — first frame = entry point, last frame = crash site, and the crash-site (last) frame is the in-app method that threw.
  • ./gradlew spotlessCheck :posthog:test passes (748 tests).

🤝 Coordination

This is a BREAKING wire-order change. Merge and release only after the ingestion pipeline's frame-order normalization gate (cymbal) is live, so older-order and newer-order events are both normalized correctly server-side.

The release must be a MINOR version bump for both posthog-android and posthog-server so the pipeline can gate normalization on $lib_version. The changeset in this PR declares minor bumps for posthog, posthog-android, and posthog-server.

📝 Checklist

  • I reviewed the submitted code.
  • I added tests to verify the changes.
  • I updated the docs if needed.
  • Ran the changeset (.changeset/canonical-frame-order.md, minor bumps).
  • Added the "release" label to the PR (hold until the normalization gate is live).

@greptile-apps

greptile-apps Bot commented Jul 3, 2026

Copy link
Copy Markdown
Contributor

Reviews (1): Last reviewed commit: "feat: send error tracking stack frames i..." | Re-trigger Greptile

@github-actions

github-actions Bot commented Jul 3, 2026

Copy link
Copy Markdown
Contributor

posthog-android Compliance Report

Date: 2026-07-20 15:47:16 UTC
Duration: 118624ms

✅ All Tests Passed!

46/46 tests passed


Capture Tests

29/29 tests passed

View Details
Test Status Duration
Format Validation.Event Has Required Fields 420ms
Format Validation.Event Has Uuid 33ms
Format Validation.Event Has Lib Properties 33ms
Format Validation.Distinct Id Is String 31ms
Format Validation.Token Is Present 35ms
Format Validation.Custom Properties Preserved 32ms
Format Validation.Event Has Timestamp 25ms
Retry Behavior.Retries On 503 7030ms
Retry Behavior.Does Not Retry On 400 4026ms
Retry Behavior.Does Not Retry On 401 4029ms
Retry Behavior.Respects Retry After Header 7028ms
Retry Behavior.Implements Backoff 17026ms
Retry Behavior.Retries On 500 7018ms
Retry Behavior.Retries On 502 7021ms
Retry Behavior.Retries On 504 7020ms
Retry Behavior.Max Retries Respected 17038ms
Deduplication.Generates Unique Uuids 42ms
Deduplication.Preserves Uuid On Retry 7018ms
Deduplication.Preserves Uuid And Timestamp On Retry 12033ms
Deduplication.Preserves Uuid And Timestamp On Batch Retry 7020ms
Deduplication.No Duplicate Events In Batch 43ms
Deduplication.Different Events Have Different Uuids 33ms
Compression.Sends Gzip When Enabled 30ms
Batch Format.Uses Proper Batch Structure 22ms
Batch Format.Flush With No Events Sends Nothing 13ms
Batch Format.Multiple Events Batched Together 43ms
Error Handling.Does Not Retry On 403 4023ms
Error Handling.Does Not Retry On 413 4024ms
Error Handling.Retries On 408 5029ms

Feature_Flags Tests

17/17 tests passed

View Details
Test Status Duration
Request Payload.Request With Person Properties Device Id 35ms
Request Payload.Flags Request Uses V2 Query Param 29ms
Request Payload.Flags Request Hits Flags Path Not Decide 27ms
Request Payload.Flags Request Omits Authorization Header 32ms
Request Payload.Token In Flags Body Matches Init 24ms
Request Payload.Groups Round Trip 25ms
Request Payload.Groups Default To Empty Object 41ms
Request Payload.Disable Geoip False Propagates As Geoip Disable False 29ms
Request Payload.Disable Geoip Omitted Defaults To False 28ms
Request Payload.Flag Keys To Evaluate Contains Only Requested Key 28ms
Request Lifecycle.No Flags Request On Init Alone 16ms
Request Lifecycle.No Flags Request On Normal Capture 23ms
Request Lifecycle.Two Flag Calls Produce Two Remote Requests 43ms
Request Lifecycle.Mock Response Value Is Returned To Caller 27ms
Retry Behavior.Retries Flags On 502 330ms
Retry Behavior.Retries Flags On 504 326ms
Side Effect Events.Get Feature Flag Captures Feature Flag Called Event 26ms

@github-actions

Copy link
Copy Markdown
Contributor

This PR hasn't seen activity in a week! Should it be merged, closed, or further worked on? If you want to keep it open, post a comment or remove the stale label – otherwise this will be closed in another week.

@github-actions github-actions Bot added the stale label Jul 10, 2026
@github-actions

Copy link
Copy Markdown
Contributor

This PR was closed due to lack of activity. Feel free to reopen if it's still relevant.

@github-actions github-actions Bot closed this Jul 20, 2026
@cat-ph cat-ph reopened this Jul 20, 2026
@cat-ph
cat-ph force-pushed the cat/canonical-frame-order branch from 2fe8604 to ec9fbb4 Compare July 20, 2026 15:41
@github-actions github-actions Bot removed the stale label Jul 21, 2026
@cat-ph
cat-ph marked this pull request as ready for review July 22, 2026 11:06
@cat-ph
cat-ph requested a review from a team as a code owner July 22, 2026 11:06
@cat-ph
cat-ph requested review from a team, ablaszkiewicz and hpouillot July 22, 2026 11:07
@greptile-apps

greptile-apps Bot commented Jul 22, 2026

Copy link
Copy Markdown
Contributor

Reviews (2): Last reviewed commit: "feat: send error tracking stack frames i..." | Re-trigger Greptile

@cat-ph
cat-ph merged commit 2f95ef9 into main Jul 22, 2026
17 checks passed
@cat-ph
cat-ph deleted the cat/canonical-frame-order branch July 22, 2026 14:43
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