diff --git a/internal/upload/batch.go b/internal/upload/batch.go index 89691835..cec0239b 100644 --- a/internal/upload/batch.go +++ b/internal/upload/batch.go @@ -226,10 +226,12 @@ func (uploadBatch *uploadBatch) initUpload() ([]string, error) { return files, nil } + var entryFile string + var err error for len(files) > 0 { - entryFile := files[0] + entryFile = files[0] files = files[1:] - err := uploadBatch.uploadFile(entryFile) + err = uploadBatch.uploadFile(entryFile) if err == nil { printSuccessfulUpload(entryFile) @@ -237,7 +239,9 @@ func (uploadBatch *uploadBatch) initUpload() ([]string, error) { } } - return files, errors.New("failed to initialize a scan due to badly formatted files") + errStr := fmt.Sprintf("failed to initialize a scan due to badly formatted files, initial upload file %s got the following error: %s", entryFile, err.Error()) + + return files, errors.New(errStr) } type uploadedFile struct { diff --git a/internal/upload/batch_test.go b/internal/upload/batch_test.go index 4f9c446a..ba9c9bdb 100644 --- a/internal/upload/batch_test.go +++ b/internal/upload/batch_test.go @@ -102,6 +102,8 @@ func TestInitUploadBadFile(t *testing.T) { assert.Empty(t, files) assert.ErrorContains(t, err, "failed to initialize a scan due to badly formatted files") + assert.ErrorContains(t, err, "testdata/misc/requirements.txt") + assert.ErrorContains(t, err, "tried to upload empty file") } func TestInitUpload(t *testing.T) {