Skip to content

Commit 52b1509

Browse files
committed
fix: guard against missing plugin directory in config loads
`find_plugin_dir` can return `None` if a plugin cannot be found. Passing this null value to `files.get_abs_path` caused crashes during config retrieval. `get_plugin_config` and `get_default_plugin_config` now check for a valid directory and return early if it is missing.
1 parent 4237e9e commit 52b1509

1 file changed

Lines changed: 9 additions & 6 deletions

File tree

helpers/plugins.py

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -607,9 +607,10 @@ def get_plugin_config(
607607

608608
# use default config if not found
609609
if not file_path:
610-
file_path = files.get_abs_path(
611-
find_plugin_dir(plugin_name), CONFIG_DEFAULT_FILE_NAME
612-
)
610+
plugin_dir = find_plugin_dir(plugin_name)
611+
if not plugin_dir:
612+
return None
613+
file_path = files.get_abs_path(plugin_dir, CONFIG_DEFAULT_FILE_NAME)
613614
default_used = True
614615

615616
result = None
@@ -635,9 +636,11 @@ def get_plugin_config(
635636

636637

637638
def get_default_plugin_config(plugin_name: str):
638-
file_path = files.get_abs_path(
639-
find_plugin_dir(plugin_name), CONFIG_DEFAULT_FILE_NAME
640-
)
639+
plugin_dir = find_plugin_dir(plugin_name)
640+
if not plugin_dir:
641+
return None
642+
643+
file_path = files.get_abs_path(plugin_dir, CONFIG_DEFAULT_FILE_NAME)
641644

642645
# call plugin hook to get the result
643646
result = call_plugin_hook(

0 commit comments

Comments
 (0)