Repository navigation
Conversation
OutboxSender captured the event or transaction through the SDK and then sent each attachment in its own envelope, so filtering or sampling out the parent left orphaned attachments. Collect the attachments of a single-parent envelope up front and pass them on the capture hint, so the client sends them in the same envelope and drops them with the parent. Fixes getsentry#6067
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
Want fixes drafted automatically? Bugbot Autofix can create code changes for findings. A team admin can enable Autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit 9097b0b. Configure here.
…ter on main main dropped anyVararg in favor of fixed-arity ILogger.log overloads, so verify the exact error log for null and mismatched parents instead.
|
This branch is now up to date with main. CHANGELOG.md was the only conflict: two releases went out since this PR opened, so the outbox attachment entry moves to a new Unreleased Fixes section and the released entries stay as they are on main. In OutboxSenderTest.kt the invalid parent test now checks the exact error log for a null or mismatched parent, since main replaced the varargs logger matcher with fixed-arity overloads, and it picks up main's trailing comma style. |

📜 Description
OutboxSender.processEnvelopenow sends an outbox envelope's attachments in the same envelope as its event or transaction, instead of one standalone envelope per attachment. IfbeforeSend, an event processor or sampling drops the parent, its attachments are dropped with it.For an envelope with exactly one Event or Transaction item, the sender collects every attachment up front (so attachments before or after the parent both work), wraps each item's data in the existing
Attachment(Callable<byte[]>, filename, contentType, attachmentType, addToTransactions)constructor, and adds them to the hint forcaptureEvent/captureTransaction.SentryClientalready builds the combined envelope fromhint.getAttachments(), andaddToTransactionsis set for transaction parents sofilterForTransactionkeeps them. The hint's previous attachments are restored infinally, sinceHint.clear()does not clear attachments.Unchanged paths:
Grouped attachments now go through
SentryEnvelopeItem.fromAttachment, so they follow the configured per-attachmentmaxAttachmentSize. There is no aggregate envelope cap; the issue raises one as a proposal, and this PR does not add it.💡 Motivation and Context
Native crash attachments (for example
event.minidump) were ingested even when the event that owns them was filtered or sampled out, which produced orphaned attachments.Fixes #6067
💚 How did you test it?
New tests in
OutboxSenderTest.kt, several of them through a realSentryClient,JsonSerializerandEnvelopeReaderwith a recording transport:Commands (JDK 21):
./gradlew :sentry:test --tests="*OutboxSenderTest*": passes./gradlew :sentry:test --tests="*SentryClientTest*": passes./gradlew :sentry:spotlessCheck: passes./gradlew :sentry:updateKotlinAbi: no API file changes📝 Checklist
sendDefaultPIIis enabled.🔮 Next steps
The changelog entry gets this PR's link once the number exists.
AI was used for assistance.