From f2d619cd8ee817ad5e5a81299818c3e9e3cccf99 Mon Sep 17 00:00:00 2001 From: ykeremy Date: Wed, 2 Oct 2024 19:28:40 +0000 Subject: [PATCH] =?UTF-8?q?=F0=9F=94=84=20synced=20local=20'skyvern/'=20wi?= =?UTF-8?q?th=20remote=20'skyvern/'?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit > [!IMPORTANT] > Update `SendEmailBlock` to log a warning for missing files or directories instead of raising an error, ensuring smoother email sending. > > - **Behavior**: > - Update `_get_file_paths` in `SendEmailBlock` to log a warning if a file or directory is missing instead of raising an error. > - Handles paths that are URLs or S3 URIs separately, ensuring they are added to `file_paths` if valid. > - **Logging**: > - Adds a warning log for missing files or directories in `_get_file_paths`. > > This description was created by [Ellipsis](https://www.ellipsis.dev?ref=Skyvern-AI%2Fskyvern-cloud&utm_source=github&utm_medium=referral) for 6b1c5b609f14f473b80586c2b212f5b12ceac486. It will automatically update as commits are pushed. --- skyvern/forge/sdk/workflow/models/block.py | 29 +++++++++++++++------- 1 file changed, 20 insertions(+), 9 deletions(-) diff --git a/skyvern/forge/sdk/workflow/models/block.py b/skyvern/forge/sdk/workflow/models/block.py index 86c6f9b92..d4a77dc47 100644 --- a/skyvern/forge/sdk/workflow/models/block.py +++ b/skyvern/forge/sdk/workflow/models/block.py @@ -868,16 +868,27 @@ def _get_file_paths(self, workflow_run_context: WorkflowRunContext, workflow_run ) # if the file path is a directory, add all files in the directory, skip directories, limit to 10 files - if os.path.exists(path) and os.path.isdir(path): - for file in os.listdir(path): - if os.path.isdir(os.path.join(path, file)): - LOG.warning("SendEmailBlock: Skipping directory", file=file) - continue - file_path = os.path.join(path, file) - file_paths.append(file_path) - else: - # covers the case where the file path is a single file, a url, or an S3 uri + if os.path.exists(path): + if os.path.isdir(path): + for file in os.listdir(path): + if os.path.isdir(os.path.join(path, file)): + LOG.warning("SendEmailBlock: Skipping directory", file=file) + continue + file_path = os.path.join(path, file) + file_paths.append(file_path) + else: + # covers the case where the file path is a single file + file_paths.append(path) + # check if path is a url, or an S3 uri + elif ( + path.startswith("http://") + or path.startswith("https://") + or path.startswith("s3://") + or path.startswith("www.") + ): file_paths.append(path) + else: + LOG.warning("SendEmailBlock: File not found", file_path=path) return file_paths