Skip to content

feat: expose attachment types#1700

Open
jpnurmi wants to merge 4 commits intomasterfrom
jpnurmi/feat/attachment-type
Open

feat: expose attachment types#1700
jpnurmi wants to merge 4 commits intomasterfrom
jpnurmi/feat/attachment-type

Conversation

@jpnurmi
Copy link
Copy Markdown
Collaborator

@jpnurmi jpnurmi commented May 5, 2026

Allow downstream SDKs to attach files and bytes with standard Sentry attachment types, such as event.view_hierarchy or event.minidump.

This is more flexible than sentry_options_add_view_hierarchy() that a) requires a file on the disk, which must be frequently updated in case of view hierarchy, and b) pushes session management to the downstream SDKs, because they don't have access to the .run directory for multi-process support and automatic cleanup.

Expose attachment type setters together with well-known type constants
so downstream SDKs can mark attachments such as view hierarchy payloads
as "event.view_hierarchy".

Co-Authored-By: OpenAI Codex <noreply@openai.com>
@github-actions
Copy link
Copy Markdown

github-actions Bot commented May 5, 2026

Messages
📖 Do not forget to update Sentry-docs with your feature once the pull request gets approved.

Generated by 🚫 dangerJS against e4abe3d

Copy link
Copy Markdown

@cursor cursor Bot left a comment

Choose a reason for hiding this comment

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

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit e4abe3d. Configure here.

"\"filename\":\"%s\"}\n",
file_size, content_type, filename ? filename : "attachment");
file_size,
attachment_type ? attachment_type : SENTRY_ATTACHMENT_TYPE_GENERIC,
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Empty attachment_type written for generic attachments in crash daemon

High Severity

When generic attachments lack an attachment_type key in the JSON manifest, sentry_value_as_string() returns "" (empty string, not NULL). The check attachment_type ? attachment_type : SENTRY_ATTACHMENT_TYPE_GENERIC only guards against NULL, so "" passes through, producing "attachment_type":"" in the envelope header instead of "attachment_type":"event.attachment". The same file correctly handles this at line 275 using (attachment_type && *attachment_type), but write_attachment_to_envelope does not dereference to check for empty string.

Additional Locations (1)
Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit e4abe3d. Configure here.

@limbonaut
Copy link
Copy Markdown
Collaborator

limbonaut commented May 5, 2026

Should we deprecate sentry_options_add_view_hierarchy? It'll be just a shortcut, not a very useful one.

@jpnurmi
Copy link
Copy Markdown
Collaborator Author

jpnurmi commented May 5, 2026

Should we deprecate sentry_options_add_view_hierarchy? It'll be just a shortcut, not a very useful one.

Hmm, yeah, we probably could. Besides sentry-native and its forks and vendored copies, I can only find public references in sentry-godot and sentry-docs.

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