From 7c5da8ea985dd9397ddfb1cc1117ecb08452c6ec Mon Sep 17 00:00:00 2001 From: Randell Callahan Date: Mon, 7 Aug 2023 14:34:33 -0600 Subject: [PATCH] batches: File upload error handling (#1015) * Add the filename to the error to help determine which file is erroring * Shadow the error to prevent the error being returned later on --- cmd/src/batch_common.go | 2 +- internal/batches/service/remote.go | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/cmd/src/batch_common.go b/cmd/src/batch_common.go index e16aa38fcb..57b248cf06 100644 --- a/cmd/src/batch_common.go +++ b/cmd/src/batch_common.go @@ -535,7 +535,7 @@ func executeBatchSpec(ctx context.Context, opts executeBatchSpecOpts) (err error } if hasWorkspaceFiles { execUI.UploadingWorkspaceFiles() - if err = svc.UploadBatchSpecWorkspaceFiles(ctx, batchSpecDir, string(id), batchSpec.Steps); err != nil { + if err := svc.UploadBatchSpecWorkspaceFiles(ctx, batchSpecDir, string(id), batchSpec.Steps); err != nil { // Since failing to upload workspace files should not stop processing, just warn execUI.UploadingWorkspaceFilesWarning(errors.Wrap(err, "uploading workspace files")) } else { diff --git a/internal/batches/service/remote.go b/internal/batches/service/remote.go index 1e57701f7a..8db0e09e45 100644 --- a/internal/batches/service/remote.go +++ b/internal/batches/service/remote.go @@ -213,7 +213,7 @@ func createFormFile(w *multipart.Writer, workingDir string, mountPath string) er return err } if fileStat.Size() > maxFileSize { - return errors.New("file exceeds limit of 10MB") + return errors.Newf("file %q exceeds limit of 10MB", mountPath) } filePath, fileName := filepath.Split(mountPath)