Skip to content

Conversation

@jpnurmi
Copy link
Collaborator

@jpnurmi jpnurmi commented Jan 2, 2026

This PR provides a solution to the problem described in

Problem

Sentry.NET integration tests run Android apps twice:

  1. The first run triggers a crash, such as SentrySDK.CauseCrash(CrashType.Java). It might succeed in sending the crash envelope to Sentry right away, or hit a timeout and leave the envelope cached on disk.
  2. A second run ensures that a potentially unsent cached envelope is flushed.

The problem is that the request from the first run might go through to the server, while the client hits a timeout and quits before receiving a response back. In this case, the second run sends the cached envelope again. While a real Sentry server would discard the duplicate, the test server records both, causing test assertions to fail.

Solution

InvokeSentryResult::Events() extracts unique event payloads from envelopes.

@jpnurmi jpnurmi requested a review from vaind January 2, 2026 14:00
@github-actions
Copy link
Contributor

github-actions bot commented Jan 2, 2026

Warnings
⚠️ Could not load custom Dangerfile: .github/test-dangerfile-curl.js Error: ENOENT: no such file or directory, lstat '/github/workspace/.github/test-dangerfile-curl.js'
Messages
📖 Do not forget to update Sentry-docs with your feature once the pull request gets approved.

Generated by 🚫 dangerJS against b8b8f54

}
}
}
catch { }
Copy link
Contributor

@vaind vaind Jan 5, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do we need to swallow exceptions here? If it's because of the access to event_id, you could use for example $header | Select-Object -ExpandProperty event_id -ErrorAction SilentlyContinue or $header.PsObject.Properties['event_id']?.Value

$header = $lines[0].Trim() | ConvertFrom-Json
if ($header.event_id -and $ids -notcontains $header.event_id)
{
$body = $lines | Select-Object -Skip 1 | Where-Object {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This assumes single event in an envelope - is that OK?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think so. According to the docs, "event" items may occur at most once per envelope: https://develop.sentry.dev/sdk/data-model/envelope-items/#event

Copy link
Contributor

@vaind vaind left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM with some questions. Consider logging in catch blocks as well as when an event is being skipped because another one has the same ID

@vaind vaind merged commit f2f33e2 into main Jan 5, 2026
20 checks passed
jpnurmi added a commit to getsentry/sentry-dotnet that referenced this pull request Jan 5, 2026
@vaind vaind deleted the feat/events branch January 5, 2026 13:51
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