fix(07): CR-02 call cancel() explicitly after S3 Delete, not via defer

Co-Authored-By: Claude Sonnet 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
Arthur Belleville 2026-05-15 18:53:04 +02:00
parent 62edbca44e
commit fbda7cbe5e
No known key found for this signature in database

View file

@ -202,10 +202,10 @@ func FileUploadHandler(deps FilesDeps) http.HandlerFunc {
slog.Default().Error("files upload: InsertTabloFile failed", "tablo_id", tablo.ID, "s3_key", s3Key, "err", err)
// Best-effort S3 cleanup — orphan prevention until Phase 6 reconciler exists.
cleanupCtx, cancel := context.WithTimeout(context.Background(), 10*time.Second)
defer cancel()
if delErr := deps.Files.Delete(cleanupCtx, s3Key); delErr != nil {
slog.Default().Error("files upload: S3 cleanup after DB failure", "s3_key", s3Key, "err", delErr)
}
cancel() // call immediately after Delete, not via defer
http.Error(w, "internal server error", http.StatusInternalServerError)
return
}