fix: add size limits for inline attachment embedding#195
Merged
Conversation
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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 syncparse_delta_bundle()rejects individual sidecar entries exceeding 100 MiB (MAX_INLINE_ATTACHMENT_BYTES) as defense-in-depth against oversized blobs from peersWorkspace::get_attachment_size()for lightweight size lookups without reading/decrypting blobsgenerate_deltas_for_peerscommand updated to handle multiple bundles per peer, with incremental watermark advancementTest plan
chunk_operations_by_attachment_size— no attachments, within limit, overflow split, oversized single attachment, interleaved ops, empty inputcargo clippyclean,cargo fmtcleanCloses #184