@@ -521,6 +521,20 @@ var _ = Describe("V1", func() {
521521 errorsTest .ExpectErrorJSON (request .ErrorResourceNotFoundWithID (id ), res .WriteInputs [0 ])
522522 })
523523
524+ It ("responds with not found error when the client returns a blob but the blob has no content" , func () {
525+ // This has happened when blob creation succeeded but the request context canceled before the contents finished uploading to S3 so there is a "stray" blob w/o content
526+ deviceLogsBlob := blobTest .RandomDeviceLogsBlob ()
527+ client .GetDeviceLogsBlobOutputs = []blobTest.GetDeviceLogsBlobOutput {{Blob : deviceLogsBlob }}
528+ client .GetDeviceLogsContentOutputs = []blobTest.GetDeviceLogsContentOutput {{Error : request .ErrorResourceNotFoundWithID (* deviceLogsBlob .ID )}}
529+ res .WriteOutputs = []testRest.WriteOutput {{BytesWritten : 0 , Error : nil }}
530+
531+ handlerFunc (res , req )
532+ Expect (res .WriteHeaderInputs ).To (Equal ([]int {http .StatusNotFound }))
533+ Expect (res .HeaderOutput ).To (Equal (& http.Header {"Content-Type" : []string {"application/json; charset=utf-8" }}))
534+ Expect (res .WriteInputs ).To (HaveLen (1 ))
535+ errorsTest .ExpectErrorJSON (request .ErrorResourceNotFoundWithID (* deviceLogsBlob .ID ), res .WriteInputs [0 ])
536+ })
537+
524538 It ("responds successfully with headers" , func () {
525539 deviceLogsBlob := blobTest .RandomDeviceLogsBlob ()
526540 content := blob .NewDeviceLogsContent ()
@@ -607,6 +621,19 @@ var _ = Describe("V1", func() {
607621 errorsTest .ExpectErrorJSON (request .ErrorResourceNotFoundWithID (id ), res .WriteInputs [0 ])
608622 })
609623
624+ It ("responds with not found error when the client returns a blob but the blob has no content" , func () {
625+ deviceLogsBlob := blobTest .RandomDeviceLogsBlob ()
626+ deviceLogsBlob .UserID = pointer .FromString (userID )
627+ client .GetDeviceLogsBlobOutputs = []blobTest.GetDeviceLogsBlobOutput {{Blob : deviceLogsBlob }}
628+ client .GetDeviceLogsContentOutputs = []blobTest.GetDeviceLogsContentOutput {{Error : request .ErrorResourceNotFoundWithID (* deviceLogsBlob .ID )}}
629+ res .WriteOutputs = []testRest.WriteOutput {{BytesWritten : 0 , Error : nil }}
630+
631+ handlerFunc (res , req )
632+ Expect (res .WriteHeaderInputs ).To (Equal ([]int {http .StatusNotFound }))
633+ Expect (res .HeaderOutput ).To (Equal (& http.Header {"Content-Type" : []string {"application/json; charset=utf-8" }}))
634+ Expect (res .WriteInputs ).To (HaveLen (1 ))
635+ errorsTest .ExpectErrorJSON (request .ErrorResourceNotFoundWithID (* deviceLogsBlob .ID ), res .WriteInputs [0 ])
636+ })
610637 It ("responds successfully with headers for user's own logs content" , func () {
611638 deviceLogsBlob := blobTest .RandomDeviceLogsBlob ()
612639 deviceLogsBlob .UserID = pointer .FromString (userID )
0 commit comments