Skip to content

fix: match SDK capture frames across demangler renderings - #179

Merged
cat-ph merged 1 commit into
mainfrom
cat/demangler-robust-frame-strip
Jul 10, 2026
Merged

fix: match SDK capture frames across demangler renderings#179
cat-ph merged 1 commit into
mainfrom
cat/demangler-robust-frame-strip

Conversation

@cat-ph

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

Copy link
Copy Markdown
Contributor

Problem

CI on main went red after #176 merged: from_error_builds_exception_list_with_stacktrace fails on Linux with expected user frame last, got "<posthog_rs::error_tracking::Exception>::from_error::<...>".

Root cause is not the wire-order flip itself: is_internal_capture_frame matches SDK capture helpers by substring (e.g. Exception::from_error), but newer toolchain/demangler output renders qualified paths as <posthog_rs::error_tracking::Exception>::from_error::<T> — the closing > breaks the substring match, so the SDK frame survives the strip and sits at the crash-site end of the canonical order. The PR's own CI was green a week earlier under the older rendering, and macOS still renders bracket-free, which is why this only surfaced on the post-merge Linux run. Exception::from_message and Client::capture_exception had the same latent hole.

Released 0.19.0 carries the bug: manual from_error/capture_exception captures built under newer toolchains keep one SDK frame at the stack tail (consistent per error, so grouping is stable — but the tail frame is wrong and the fingerprint includes SDK noise).

Changes

  • is_internal_capture_frame strips </> from the demangled name before matching, so both renderings (and monomorphized generic suffixes) hit all existing patterns. Panic/unwind runtime frames remain deliberately unmatched, as before.
  • Regression test pinning both renderings for the affected helpers, plus a non-SDK name that must not match.
  • patch changeset → 0.19.1. The cymbal wire-order cutoff is 0.19.0, so the patch passes the gate as canonical, which is correct — it contains the flip.

How did you test this code?

Automated only:

  • Reproduced the exact main failure in a Linux container (rust:1, current stable), then verified the fix: all 28 error_tracking tests pass there, including the previously failing one.
  • Full cargo test --lib on macOS (188 passed) — the older bracket-free rendering still matches.
  • Pre-existing personal_api_key deprecation warnings in test_on_error.rs (from feat: add secret_key config, deprecate personal_api_key #174) are untouched/out of scope.

🤖 Agent context

Autonomy: Human-driven (agent-assisted)

Claude Code diagnosed and fixed this under my direction: pulled the failing main run, reproduced in a Linux container to get the assertion text CI logs omitted, bisected the discrepancy to demangler rendering differences rather than the #176 logic, and validated on both renderings.

@cat-ph
cat-ph marked this pull request as ready for review July 10, 2026 16:33
@cat-ph
cat-ph requested a review from a team as a code owner July 10, 2026 16:33
@github-actions

Copy link
Copy Markdown
Contributor

posthog-rs-v0 Compliance Report

Date: 2026-07-10 16:35:30 UTC
Duration: 15547ms

✅ All Tests Passed!

46/46 tests passed


Capture Tests

29/29 tests passed

View Details
Test Status Duration
Format Validation.Event Has Required Fields 143ms
Format Validation.Event Has Uuid 143ms
Format Validation.Event Has Lib Properties 144ms
Format Validation.Distinct Id Is String 144ms
Format Validation.Token Is Present 143ms
Format Validation.Custom Properties Preserved 144ms
Format Validation.Event Has Timestamp 148ms
Retry Behavior.Retries On 503 5153ms
Retry Behavior.Does Not Retry On 400 2150ms
Retry Behavior.Does Not Retry On 401 2143ms
Retry Behavior.Respects Retry After Header 5099ms
Retry Behavior.Implements Backoff 15101ms
Retry Behavior.Retries On 500 5103ms
Retry Behavior.Retries On 502 5099ms
Retry Behavior.Retries On 504 5097ms
Retry Behavior.Max Retries Respected 15100ms
Deduplication.Generates Unique Uuids 100ms
Deduplication.Preserves Uuid On Retry 5023ms
Deduplication.Preserves Uuid And Timestamp On Retry 10031ms
Deduplication.Preserves Uuid And Timestamp On Batch Retry 5034ms
Deduplication.No Duplicate Events In Batch 27ms
Deduplication.Different Events Have Different Uuids 23ms
Compression.Sends Gzip When Enabled 23ms
Batch Format.Uses Proper Batch Structure 25ms
Batch Format.Flush With No Events Sends Nothing 37ms
Batch Format.Multiple Events Batched Together 106ms
Error Handling.Does Not Retry On 403 2089ms
Error Handling.Does Not Retry On 413 2095ms
Error Handling.Retries On 408 5091ms

Feature_Flags Tests

17/17 tests passed

View Details
Test Status Duration
Request Payload.Request With Person Properties Device Id 57ms
Request Payload.Flags Request Uses V2 Query Param 61ms
Request Payload.Flags Request Hits Flags Path Not Decide 22ms
Request Payload.Flags Request Omits Authorization Header 27ms
Request Payload.Token In Flags Body Matches Init 42ms
Request Payload.Groups Round Trip 36ms
Request Payload.Groups Default To Empty Object 36ms
Request Payload.Disable Geoip False Propagates As Geoip Disable False 45ms
Request Payload.Disable Geoip Omitted Defaults To False 45ms
Request Payload.Flag Keys To Evaluate Contains Only Requested Key 36ms
Request Lifecycle.No Flags Request On Init Alone 16ms
Request Lifecycle.No Flags Request On Normal Capture 50ms
Request Lifecycle.Two Flag Calls Produce Two Remote Requests 50ms
Request Lifecycle.Mock Response Value Is Returned To Caller 36ms
Retry Behavior.Retries Flags On 502 245ms
Retry Behavior.Retries Flags On 504 243ms
Side Effect Events.Get Feature Flag Captures Feature Flag Called Event 46ms

@greptile-apps

greptile-apps Bot commented Jul 10, 2026

Copy link
Copy Markdown

Reviews (1): Last reviewed commit: "fix: match SDK capture frames across dem..." | Re-trigger Greptile

Comment thread src/error_tracking.rs
@github-actions

Copy link
Copy Markdown
Contributor

posthog-rs-v1 Compliance Report

Date: 2026-07-10 16:36:14 UTC
Duration: 22654ms

✅ All Tests Passed!

111/111 tests passed


Capture_V1 Tests

94/94 tests passed

View Details
Test Status Duration
Endpoint And Method.Targets V1 Endpoint 94ms
Endpoint And Method.Does Not Use Legacy Endpoints 95ms
Required Headers.Has Authorization Bearer Header 95ms
Required Headers.Has Content Type Json 94ms
Required Headers.Has Posthog Sdk Info Format 96ms
Required Headers.Has Posthog Attempt Header 93ms
Required Headers.Has Posthog Request Id 93ms
Required Headers.Has Posthog Request Timestamp 97ms
Required Headers.Has User Agent 95ms
Body Format.Body Has Created At And Batch 92ms
Body Format.No Api Key In Body 76ms
Body Format.No Sent At In Body 89ms
Event Format.Event Has Required Root Fields 87ms
Event Format.Event Uuid Is Valid 90ms
Event Format.Event Timestamp Is Rfc3339 89ms
Event Format.Distinct Id Is String 88ms
Event Format.Distinct Id At Root Not Properties 88ms
Event Format.Custom Properties Preserved 90ms
Event Format.Set Properties Preserved 87ms
Event Format.Set Once Properties Preserved 84ms
Event Format.Groups Properties Preserved 83ms
Event Format.Sdk Generates Uuid If Not Provided 75ms
Event Format.Event Has Required Root Fields Batch 101ms
Event Format.Event Uuid Is Valid Batch 101ms
Event Format.Event Timestamp Is Rfc3339 Batch 101ms
Event Format.Distinct Id Is String Batch 100ms
Event Format.Distinct Id At Root Not Properties Batch 100ms
Event Format.Custom Properties Preserved Batch 99ms
Event Format.Set Properties Preserved Batch 99ms
Event Format.Set Once Properties Preserved Batch 98ms
Event Format.Groups Properties Preserved Batch 89ms
Event Format.Sdk Generates Uuid If Not Provided Batch 85ms
Batch Behavior.Multiple Events In Single Batch 115ms
Batch Behavior.Batch Envelope Smoke 95ms
Batch Behavior.Flush With No Events Sends Nothing 58ms
Batch Behavior.Flush At Triggers Batch 1080ms
Batch Behavior.Created At Reflects Batch Creation Time 63ms
Deduplication.Generates Unique Uuids 105ms
Deduplication.Different Events Same Content Different Uuids 68ms
Deduplication.Preserves Uuid On Retry 5068ms
Deduplication.Preserves Timestamp On Retry 5041ms
Deduplication.Preserves Uuid And Timestamp On Batch Retry 5069ms
Deduplication.No Duplicate Events In Batch 85ms
Header Behavior On Retry.Attempt Header Starts At One 49ms
Header Behavior On Retry.Attempt Header Increments On Retry 10049ms
Header Behavior On Retry.Request Id Preserved On Retry 5032ms
Header Behavior On Retry.Different Requests Have Different Request Ids 2041ms
Header Behavior On Retry.Request Timestamp Changes On Retry 5030ms
Response Format Validation.Success Response Has Uuid Keyed Results 29ms
Response Format Validation.Success Response Has Ok For Each Event 20ms
Response Format Validation.Success No Retry After When All Ok 20ms
Response Format Validation.Success Retry After Present When Retry Events 21ms
Response Format Validation.Success No Retry After When Drop Only 22ms
Response Format Validation.Response Echoes Request Id 19ms
Retry Behavior.Retries On 408 5022ms
Retry Behavior.Retries On 500 5016ms
Retry Behavior.Retries On 503 5016ms
Retry Behavior.Retries On 504 5015ms
Retry Behavior.Retryable Errors Have Retry After 2016ms
Retry Behavior.Respects Retry After On Retryable Error 8015ms
Retry Behavior.Does Not Retry On 400 2023ms
Retry Behavior.Does Not Retry On 401 2021ms
Retry Behavior.Does Not Retry On 402 2017ms
Retry Behavior.Does Not Retry On 413 2016ms
Retry Behavior.Does Not Retry On 415 2015ms
Retry Behavior.Non Retryable Errors Have No Retry After 2017ms
Retry Behavior.Implements Backoff 15023ms
Retry Behavior.Max Retries Respected 15021ms
Partial Batch Handling.Handles 200 Full Success 2034ms
Partial Batch Handling.Handles 200 With All Ok 3029ms
Partial Batch Handling.Does Not Retry Dropped Events 3029ms
Partial Batch Handling.Does Not Retry Limited Events 3015ms
Partial Batch Handling.Prunes Ok Events On Partial Retry 5015ms
Partial Batch Handling.Prunes Dropped Events On Partial Retry 5018ms
Partial Batch Handling.Retries Only Retry Events From Partial 5017ms
Partial Batch Handling.Partial Retry Preserves Uuids 5017ms
Partial Batch Handling.Partial Retry Attempt Header Increments 5022ms
Partial Batch Handling.Partial Retry Request Id Preserved 5022ms
Partial Batch Handling.Respects Retry After On Partial 5015ms
Partial Batch Handling.Unknown Result Treated As Terminal 3017ms
Partial Batch Handling.Mixed Ok Drop Limited No Retry 3019ms
Compression.Sends Gzip Content Encoding 14ms
Compression.No Content Encoding When Disabled 13ms
Compression.Compressed Body Is Decompressible 13ms
Error Handling.Does Not Retry On Unknown 4Xx 2013ms
Event Options.Cookieless Mode Override 15ms
Event Options.Disable Skew Correction Override 14ms
Event Options.Process Person Profile Override 14ms
Event Options.Product Tour Id Override 13ms
Event Options.Unset Options Omitted 13ms
Event Options.Options Override In Batch 14ms
Geoip And Historical Migration.Geoip Disable Injected Into Properties 13ms
Geoip And Historical Migration.Historical Migration Set In Body 13ms
Geoip And Historical Migration.Historical Migration Absent By Default 13ms

Feature_Flags Tests

17/17 tests passed

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

@cat-ph
cat-ph merged commit 31213ee into main Jul 10, 2026
25 checks passed
@cat-ph
cat-ph deleted the cat/demangler-robust-frame-strip branch July 10, 2026 16:37
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.

2 participants