Story #21 File Uploads · Payload Limits · Streaming

The Upload That Passed the API but Never Reached the Archive

"The API accepted the upload. Why did the medical document never appear in the patient's record?"

Aster Health Exchange had mismatched request size limits across its gateway, proxy, and application. Larger clinical uploads failed inconsistently. When a partial failure left binary objects stored but metadata uncommitted, retrying clients created orphaned files with no linked patient record.

What happened

Aster Health Exchange accepted clinical documents through a multipart upload API, documenting a maximum file size of 50 MB. A new hospital integration began sending larger scanned records—42 MB PDFs—and started experiencing inconsistent results.

The API gateway accepted requests at the documented limit. But a reverse proxy in front of the application had a smaller body limit. Depending on routing, some uploads were rejected with HTTP 413, some were terminated mid-transfer, and others reached the application but timed out while buffering the full file in memory.

One failure mode was particularly damaging: a binary object was written to storage successfully, but the subsequent database metadata commit failed. The client received a server error and retried, creating a second binary object. The first remained orphaned—stored, but not associated with any patient record. Hospital staff couldn’t find documents that the system reported as uploaded.

Root cause

The upload API was tested with small files and successful end-to-end requests. No tests covered files at or near the limit, interrupted transfers, or the atomicity of storage and metadata operations. Infrastructure limits weren’t aligned across layers, and the error contract didn’t distinguish retryable from non-retryable failures.

The fix

Request-size and timeout policies were aligned across all infrastructure layers. The application moved to streaming uploads. A durable upload session with stable upload IDs and explicit states (initiated, receiving, validated, stored, committed) made retries safe. Binary object storage and metadata creation were tied together in a recoverable workflow with orphan cleanup.

Lesson learned

A file upload API contract is more than a maximum byte count. It includes transport limits at every layer, interruption handling, storage atomicity, and retry safety. Test uploads at and above every documented limit—and test what happens when only some steps succeed.

The Upload That Passed the API but Never Reached the Archive