A file upload crosses at least two state systems: object storage and the application database. If one succeeds and the other fails, users can see missing attachments or the service can retain files nobody can reach or manage.
Model the lifecycle explicitly instead of treating upload as one instantaneous action. The product should be able to explain whether a file is pending, available, failed, removed, or awaiting cleanup.
Give each upload a stable application identity
Associate the upload with a trusted owner and intended resource before or during the controlled upload flow. Store a stable object reference and relevant status rather than relying on a user-supplied filename as identity.
Define which component confirms storage completion and which marks the file available. The browser reporting success is not enough if the application has not verified the expected object and ownership under the chosen storage design.
Rehearse a fictional study voice recording
Imagine a participant records feedback for a study. The audio object uploads successfully, but the database write linking it to the response fails. In another case, the response record is created while the upload is interrupted.
The first case needs a way to reconcile or remove an unlinked object. The second needs a visible pending or failed attachment state rather than a playable control pointing nowhere. Use fictional audio or harmless fixtures for the exercise, not private participant recordings.
Test interrupted upload, repeated completion notification, cancelled submission, deleted study, and lost permission before finalisation. Confirm the object cannot be attached to a different owner's resource merely by changing an identifier in the request.
Make cleanup a controlled operation
Create a reconciliation process that compares expected records and stored objects under a documented age and state policy. Avoid deleting every unlinked object immediately; an in-progress upload may legitimately have no final link yet.
Record cleanup outcomes and make failures observable. Storage deletion can fail independently of database updates. A removed attachment should not remain publicly retrievable because the application only hid its row.
The tradeoff is synchronous certainty versus user waiting. Waiting for every step before confirming can simplify the visible contract but increase latency. A staged flow can improve responsiveness while requiring durable states and recovery. Choose the user-facing promise first, then test that the backend can fulfil it.
The StackFlight product account describes voice and text response collection. This storage-failure exercise is fictional and does not claim an incident or specify that product's storage implementation.
Questions about upload consistency
Can the filename be the database key?
It is usually a poor identity boundary because names can repeat or change. Use an application-controlled reference with explicit ownership.
Is hiding a failed attachment enough?
No. Track whether a stored object or incomplete record remains and handle it under the recovery and retention policy.
What should be tested first?
Interrupt each boundary between intent, storage, record linking, and confirmation. Bring the resulting states to a file-workflow review before adding automated cleanup.