diff --git a/server.py b/server.py index c9ffcaa0d..9be21f21c 100644 --- a/server.py +++ b/server.py @@ -377,6 +377,10 @@ class PromptServer(): type_dir = folder_paths.get_temp_directory() elif dir_type == "output": type_dir = folder_paths.get_output_directory() + else: + # Unrecognised type: signal "no directory" instead of falling + # through to an unbound `type_dir` (UnboundLocalError -> 500). + return None, dir_type return type_dir, dir_type @@ -401,6 +405,8 @@ class PromptServer(): image_upload_type = post.get("type") upload_dir, image_upload_type = get_dir_by_type(image_upload_type) + if upload_dir is None: + return web.Response(status=400) if image and image.file: filename = image.filename