Skip to content

fix(attachments): flush scope on updating attachments - #1934

Open
JoshuaMoelans wants to merge 6 commits into
masterfrom
joshua/fix/attachment_updates_on_scope
Open

fix(attachments): flush scope on updating attachments#1934
JoshuaMoelans wants to merge 6 commits into
masterfrom
joshua/fix/attachment_updates_on_scope

Conversation

@JoshuaMoelans

@JoshuaMoelans JoshuaMoelans commented Jul 31, 2026

Copy link
Copy Markdown
Member

Fixes #1933

Updates to attachments weren't flushed to the scope (only when adding it with sentry_attach_file). This caused updates to attachments to only apply on non-fatal events, since the native backend only knows about the state of the attachment from right before attaching it.

This fixes both questions in the original issue; attachment names are synced & so are the content_types, which initially made Sentry backend interpret the file as the default application/octet-stream which gets a Preview button (whereas the application/ztsd would not)

From the flow that UE hits on adding attachments, we see the same attach -> set_filename -> set_content_type flow that we now fix with scope syncing:

void FGenericPlatformSentrySubsystem::AddFileAttachment(TSharedPtr<ISentryAttachment> attachment)
{
	TSharedPtr<FGenericPlatformSentryAttachment> platformAttachment = StaticCastSharedPtr<FGenericPlatformSentryAttachment>(attachment);

	sentry_attachment_t* nativeAttachment =
		sentry_attach_file(TCHAR_TO_UTF8(*platformAttachment->GetPath()));

	if (!platformAttachment->GetFilename().IsEmpty())
		sentry_attachment_set_filename(nativeAttachment, TCHAR_TO_UTF8(*platformAttachment->GetFilename()));

	if (!platformAttachment->GetContentType().IsEmpty())
		sentry_attachment_set_content_type(nativeAttachment, TCHAR_TO_UTF8(*platformAttachment->GetContentType()));

	platformAttachment->SetNativeObject(nativeAttachment);

	attachments.Add(platformAttachment);
}

JoshuaMoelans and others added 5 commits July 31, 2026 10:10
`sentry_attachment_set_filename`, `_set_type` and `_set_content_type` mutated
scope-owned attachments without locking or flushing the scope. The native
backend only rewrites `<run>/__sentry-attachments` on a scope flush, so the
crash daemon read a manifest that still carried the physical basename and the
attachment type/content type from when the attachment was added.

Split each setter into a raw internal mutator and a public wrapper that mutates
under the scope lock and flushes the backend on unlock. `sentry__attachments_add_path`
uses the raw mutators, keeping options attachments, hint attachments and the
crashpad old-run envelope builder off the scope lock.

Fixes #1933

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
@codecov

codecov Bot commented Jul 31, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 72.41379% with 8 lines in your changes missing coverage. Please review.
✅ Project coverage is 75.79%. Comparing base (5bac907) to head (ba60934).

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #1934      +/-   ##
==========================================
+ Coverage   75.74%   75.79%   +0.05%     
==========================================
  Files          93       93              
  Lines       22128    22155      +27     
  Branches     3939     3945       +6     
==========================================
+ Hits        16760    16792      +32     
+ Misses       4484     4477       -7     
- Partials      884      886       +2     
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@JoshuaMoelans
JoshuaMoelans marked this pull request as ready for review July 31, 2026 10:59
@JoshuaMoelans

Copy link
Copy Markdown
Member Author

@sentry review

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.

Native backend uses physical attachment filename for hard crashes, instead of the name passed to USentryLibrary::CreateSentryAttachmentWithData()

1 participant