fix(upload): fail chunk when upload session record vanished (#2938)

When an upload session's KV record disappears mid-upload (expired TTL,
eviction, or a racing cancel/fail), MarkChunkUploaded returns
(false, nil) — the chunk request then succeeded without ever completing
the upload, leaving a placeholder permanently stuck at size 0 in
"uploading" state.

processChunkUpload now re-checks the session record on a non-complete
mark and returns CodeUploadSessionExpired when it is gone, so clients
retry loudly instead of stalling. The same guard applies to the new
ranged-PUT path (409 + retry).

Generated with [Devin](https://devin.ai)

Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
pull/3582/head
Tomas Dvorak 2 weeks ago
parent 527b828439
commit 84b29430f1

@ -205,6 +205,15 @@ func processChunkUpload(c *gin.Context, m manager.FileManager, session *fs.Uploa
if err != nil {
return err
}
if !allReceived {
// A missing session record (expired TTL, eviction, or a racing
// cancel) means completion can never trigger — fail loudly so the
// client retries instead of leaving a permanently stuck placeholder.
dep := dependency.FromContext(c)
if _, ok := dep.KV().Get(manager.UploadSessionCachePrefix + session.Props.UploadSessionID); !ok {
return serializer.NewError(serializer.CodeUploadSessionExpired, "", nil)
}
}
if allReceived {
_, err := m.CompleteUpload(ctx, session)
if err != nil {

Loading…
Cancel
Save