Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SendEmailBlock: Fail silently if file/folder is missing #898

Merged
merged 1 commit into from
Oct 2, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 20 additions & 9 deletions skyvern/forge/sdk/workflow/models/block.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
Loading