Repository navigation
fix: preserve original stacks when an empty trace is supplied - #626
Merged
Merged
Conversation
Member
Author
|
found while reviewing #621 but the issue was already there |
|
[Medium risk] Changes how empty stack traces are detected and handled. The PR appears safe to merge; the missing wrapped-error test is non-blocking. Reviews (1) · Last reviewed commit: "fix: preserve original stacks when an em..." |
Contributor
posthog-flutter Compliance ReportDate: 2026-09-30 14:05:31 UTC ✅ All Tests Passed!45/45 tests passed Capture Tests✅ 29/29 tests passed View Details
Feature_Flags Tests✅ 16/16 tests passed View Details
|
marandaneto
marked this pull request as ready for review
September 30, 2026 13:56
turnipdabeets
approved these changes
Sep 30, 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
Passing
StackTrace.emptyto exception capture skips the error's original stack and replaces it with capture-site frames. Empty string,Trace, andChainrepresentations can instead produce no frames because they are not equal toStackTrace.empty.Treat empty and whitespace-only traces as missing. Preserve a usable supplied trace first, then the error's own trace, and generate a current stack only when neither is usable. Reuse the existing own-stack extraction helper for the primary exception and check emptiness by content.
This follows the SDK spec's stack preservation requirement. There are no public API changes or known divergences in the behavior changed here.
💚 How did you test it?
PostHogException, including wrapper mechanism and handled-state preservation. Nine original regression cases and five wrapped-error cases fail on the pre-fix code. All pass with the fix.Chain.capturezone so test-harness frames cannot hide empty stacks.flutter test --no-pubinposthog_flutter: all 743 VM tests passed.make checkFormatDart,make analyzeDart, andmake checkApiDart: all passed.autoreview --mode branch --base origin/mainon commit05c1110: no actionable findings.📝 Checklist
If releasing new changes
pnpm changesetto generate a changeset fileThe changeset was omitted at the author's request.
🤖 Agent context
Autonomy: Human-driven (agent-assisted)
Pi used Git, GitHub CLI, Flutter/Dart checks, and isolated autoreview. The fix and before/after validation were performed in a dedicated worktree. The implementation reuses the existing stack extraction helper rather than adding a separate fallback path. The new tests were audited for regression sensitivity, and autoreview reported no actionable findings. Human review is required.