Goal
Parse Sentry attachment envelope items (binary payloads like screenshots, log files) and make them viewable/downloadable from the TrapFall event detail page.
Context
Attachments are fundamentally different from other envelope items — they are binary, not JSON. The current parse_envelope_text() reads line-by-line which cannot handle binary data. This phase requires rewriting the envelope parser to be length-based (read N bytes) instead of purely line-based (read until \n).
Sentry SDKs (JS/SvelteKit, Flutter, Python) can auto-attach screenshots, minidumps, and log files to error events. This is especially useful for frontend errors via @sentry/sveltekit (attachScreenshot: true).
Depends on: Phase 1 (ParsedEnvelope return type)
Attachment Envelope Format
{"type":"attachment","length":24567,"filename":"screenshot.png","attachment_type":"event.attachment","content_type":"image/png"}
<binary PNG data — exactly 24567 bytes>
Header fields:
| Field |
Type |
Description |
type |
string |
Always "attachment" |
length |
int |
Byte length of binary payload |
filename |
string |
Original filename |
attachment_type |
string? |
"event.attachment" (default), "event.minidump", custom |
content_type |
string? |
MIME type (image/png, text/plain) |
Tasks
3a. trapfall-proto — Wire types
3b. trapfall-ingest — Binary-safe parser ⚠️ breaking change
3c. trapfall-db — Schema + storage
3d. Dashboard — Attachment UI
Storage Considerations
- Attachments can be large (screenshots ~200KB, minidumps ~10MB)
- Need configurable max size limit (e.g., 50MB per file)
- Consider retention policy: auto-delete attachments older than N days
- SQLite
data column with base64 = 33% size overhead — disk storage preferred for large files
Risks
- Binary parsing is the most error-prone part of this entire milestone
- Wrong
length handling could misalign subsequent item parsing in the same envelope
- Must handle gracefully: log warning, skip attachment, continue parsing remaining items
Dependencies
Effort
~1-2 days
Sub-issues:
Goal
Parse Sentry
attachmentenvelope items (binary payloads like screenshots, log files) and make them viewable/downloadable from the TrapFall event detail page.Context
Attachments are fundamentally different from other envelope items — they are binary, not JSON. The current
parse_envelope_text()reads line-by-line which cannot handle binary data. This phase requires rewriting the envelope parser to be length-based (read N bytes) instead of purely line-based (read until\n).Sentry SDKs (JS/SvelteKit, Flutter, Python) can auto-attach screenshots, minidumps, and log files to error events. This is especially useful for frontend errors via
@sentry/sveltekit(attachScreenshot: true).Attachment Envelope Format
Header fields:
type"attachment"lengthfilenameattachment_type"event.attachment"(default),"event.minidump", customcontent_typeimage/png,text/plain)Tasks
3a.
trapfall-proto— Wire typesAttachmentstruct:filename,content_type,attachment_type,data: Vec<u8>ParsedEnvelopewithattachments: Vec<Attachment>3b.⚠️ breaking change
trapfall-ingest— Binary-safe parserparse_envelope_text()to be length-aware:item_type == "attachment"andlengthis present → read exactly N bytes from raw bufferlengthis absent → fallback to line-based JSON parsing (backward compat)parse_envelope_text()to work on&[u8]instead of&strfor the body extraction part3c.
trapfall-db— Schema + storageattachmentstabledatacolumn/data/attachments/{project_id}/{event_id}/{filename}), DB storesstorage_pathget_attachments(event_id),insert_attachment()3d. Dashboard — Attachment UI
Storage Considerations
datacolumn with base64 = 33% size overhead — disk storage preferred for large filesRisks
lengthhandling could misalign subsequent item parsing in the same envelopeDependencies
ParsedEnvelope)Effort
~1-2 days
Sub-issues: