Skip to content

Envelope writer reports success on partial/failed disk write, producing truncated envelopes #1803

Description

@Kobby-Bawuah

Description

When persisting an envelope to disk, the SDK treats the write as successful as long as any bytes were written, rather than verifying the full envelope was written. If a write fails partway (for example, the disk is full / ENOSPC), the per-item write results are not checked, so a truncated envelope is left on disk and reported as a successful write — no error is returned and nothing is logged.

The resulting envelope is malformed (e.g. a blank/missing header line and a truncated minidump attachment) and is later rejected by ingest. Because the failure is swallowed, there is no signal pointing at the real cause (the failed write).

The affected logic is in envelope_write_to_path in src/sentry_envelope.c, which determines success from the total byte count written rather than from whether each write completed. The underlying file-write helpers also do not log when a write fails or is truncated.

This is platform-independent (the serializer is shared code), though it was observed on a Windows-family target.

When does the problem happen

  • During build
  • During run-time
  • When capturing a hard crash

Environment

  • OS: Windows-family target (platform-independent code path)
  • Compiler: MSVC
  • CMake version and config: SENTRY_BACKEND=breakpad

Steps To Reproduce

  1. Configure the SDK to persist crash envelopes to disk.
  2. Induce a write failure while an envelope is being written (e.g. fill the target volume so writes fail with ENOSPC).
  3. Observe that a truncated/invalid envelope is written to disk, the write is reported as successful, and no error or warning is logged.

Log output

No error or warning is emitted on the partial-write path; the write is reported as successful. (A specific customer case, including the captured malformed envelope, is tracked in the attached Linear ticket.)

Metadata

Metadata

Assignees

Labels

Bugsomething isn't working as it shouldNativeplatform label

Fields

No fields configured for issues without a type.

Projects

Status
No status

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions