Skip to content

ref: attachment manifest - #2108

Open
jpnurmi wants to merge 2 commits into
masterfrom
jpnurmi/ref/attachment-manifest
Open

jpnurmi wants to merge 2 commits into
masterfrom
jpnurmi/ref/attachment-manifest

Conversation

@jpnurmi

@jpnurmi jpnurmi commented Sep 17, 2026

Copy link
Copy Markdown
Collaborator

Use a shared MessagePack stream for attachment manifests. The native backend uses the manifest for attachments generally, while both out-of-process crash handlers will need to use it for crash-time hint attachments (#2099) that cannot cross backend IPC. This lets Crashpad consume those attachments with the existing MessagePack reader, without having to introduce JSON support/dependencies.

Stream attachment objects directly to avoid format-specific conversion and buffer the complete manifest for a single file write. Median release benchmarks measured write/read improvements over legacy JSON of 17%/6% for one attachment, 74%/17% for 10, and 86%/24% for 100:

1 attachment 10 attachments 100 attachments
MessagePack write 2.3 us 2.4 us 11.8 us
JSON write 2.7 us 8.9 us 82.6 us
MessagePack read 1.3 us 5.6 us 54.1 us
JSON read 1.4 us 6.8 us 71.1 us

Keep legacy JSON compatibility private to the native daemon so it can still consume manifests written by older SDK versions.

@cursor cursor Bot left a comment

Copy link
Copy Markdown

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 d8eb6bb. Configure here.

Comment thread src/backends/sentry_backend_native.c
Comment thread src/sentry_attachment.c
@jpnurmi
jpnurmi force-pushed the jpnurmi/ref/attachment-manifest branch from d8eb6bb to f0d7bcf Compare September 17, 2026 16:51
@codecov

codecov Bot commented Sep 17, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 59.61538% with 63 lines in your changes missing coverage. Please review.
✅ Project coverage is 74.90%. Comparing base (4d570f3) to head (8166a35).
⚠️ Report is 3 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #2108      +/-   ##
==========================================
+ Coverage   74.83%   74.90%   +0.07%     
==========================================
  Files         103      103              
  Lines       27386    27461      +75     
  Branches     4944     4977      +33     
==========================================
+ Hits        20494    20571      +77     
- Misses       5543     5549       +6     
+ Partials     1349     1341       -8     
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Use a shared MessagePack stream for attachment manifests. The native
backend uses the manifest for attachments generally, while both
out-of-process crash handlers can also use it for crash-time hint
attachments that cannot cross backend IPC. This lets Crashpad consume
those attachments without adding JSON support.

Stream attachment objects directly to avoid format-specific conversion
and buffer the complete manifest for a single file write. Median release
benchmarks measured write/read improvements over legacy JSON of 17%/6%
for one attachment, 74%/17% for 10, and 86%/24% for 100:

                    1 attachment   10 attachments   100 attachments
  MessagePack write       2.3 us           2.4 us            11.8 us
  JSON write              2.7 us           8.9 us            82.6 us
  MessagePack read        1.3 us           5.6 us            54.1 us
  JSON read               1.4 us           6.8 us            71.1 us

Keep legacy JSON compatibility private to the native daemon so it can
still consume manifests written by older SDK versions.
@jpnurmi
jpnurmi added this pull request to stack #2113 September 18, 2026 16:49
Comment thread src/sentry_attachment.c
Comment on lines +720 to +722
sentry_path_t *attachment_path
= sentry__attachment_make_run_path(run_path, attachment);
if (!attachment_path) {

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Bug: The attachment manifest serialization code unnecessarily includes the internal uuid field for each attachment, increasing file size without providing any benefit to the reader.
Severity: MEDIUM

Suggested Fix

In the loop that builds the attachment manifest object, add a check to explicitly skip the uuid key. For example, if (strcmp(sentry_value_get_string(key), "uuid") == 0) { continue; }. This will prevent the UUID from being written to the manifest file, reducing its size and aligning with the optimization goals.

Prompt for AI Agent
Review the code at the location below. A potential bug has been identified by an AI
agent. Verify if this is a real issue. If it is, propose a fix; if not, explain why it's
not valid.

Location: src/sentry_attachment.c#L720-L722

Potential issue: When serializing the attachment manifest to MessagePack, the code
iterates through all properties of an attachment object. It includes any property of
type `SENTRY_VALUE_TYPE_STRING`, which inadvertently includes the internal `uuid`. This
UUID is an implementation detail used for in-memory deduplication and is not used by the
daemon when reading the manifest. Including it adds unnecessary data (36 characters plus
encoding overhead per attachment), which partially counteracts the performance and size
improvements intended by the refactor.

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.

1 participant