From a67831773f99910a5fa25dcff7b1511da882bdd4 Mon Sep 17 00:00:00 2001 From: Benjamin Date: Mon, 22 Jul 2024 13:24:32 +0800 Subject: [PATCH] refactor: handle missing position file gracefully (#6513) --- api/core/helper/position_helper.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/api/core/helper/position_helper.py b/api/core/helper/position_helper.py index e4ceeb652e..04675d85bb 100644 --- a/api/core/helper/position_helper.py +++ b/api/core/helper/position_helper.py @@ -14,6 +14,9 @@ def get_position_map(folder_path: str, *, file_name: str = "_position.yaml") -> :return: a dict with name as key and index as value """ position_file_name = os.path.join(folder_path, file_name) + if not position_file_name or not os.path.exists(position_file_name): + return {} + positions = load_yaml_file(position_file_name, ignore_error=True) position_map = {} index = 0