Skip to content

fix: add size limits for inline attachment embedding#195

Merged
careck merged 4 commits into
masterfrom
fix/184-attachment-size-limits
May 9, 2026
Merged

fix: add size limits for inline attachment embedding#195
careck merged 4 commits into
masterfrom
fix/184-attachment-size-limits

Conversation

@careck
Copy link
Copy Markdown
Member

@careck careck commented May 8, 2026

Summary

  • generate_delta() now chunks operations into multiple bundles when cumulative attachment payload exceeds 256 MiB (MAX_DELTA_BUNDLE_ATTACHMENT_BYTES), preventing memory spikes from large attachment batches during sync
  • parse_delta_bundle() rejects individual sidecar entries exceeding 100 MiB (MAX_INLINE_ATTACHMENT_BYTES) as defense-in-depth against oversized blobs from peers
  • Added Workspace::get_attachment_size() for lightweight size lookups without reading/decrypting blobs
  • Sync engine poll loop and Tauri generate_deltas_for_peers command updated to handle multiple bundles per peer, with incremental watermark advancement

Test plan

  • 6 unit tests for chunk_operations_by_attachment_size — no attachments, within limit, overflow split, oversized single attachment, interleaved ops, empty input
  • 1 end-to-end integration test: multiple attachments through generate → apply path
  • All 674 existing tests pass (including attachment sync, watermark recovery, relay integration)
  • cargo clippy clean, cargo fmt clean

Closes #184

careck added 4 commits May 8, 2026 22:12
Prevent memory spikes during sync when many or large attachments
accumulate between sync cycles. generate_delta() now chunks operations
into multiple bundles when cumulative attachment payload exceeds
256 MiB, and parse_delta_bundle() rejects individual sidecars over
100 MiB as defense-in-depth.

Closes #184
Both MAX_DELTA_BUNDLE_ATTACHMENT_BYTES and MAX_INLINE_ATTACHMENT_BYTES
reduced from 256/100 MiB to 10 MB to match the relay server's
per-bundle upload limit.
attach_file() now falls back to MAX_INLINE_ATTACHMENT_BYTES (10 MB)
when no workspace-level limit is set, preventing oversized attachments
that would fail to sync through the relay.
Display "18.2 MB (limit: 10.0 MB)" instead of raw byte counts.
@careck careck merged commit 5b3d8c9 into master May 9, 2026
2 checks passed
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.

Add size limits for inline attachment embedding

1 participant