From 0597be32dfab2f64a9460e6c3d6d029f67184752 Mon Sep 17 00:00:00 2001 From: parker Date: Sun, 5 Oct 2025 16:07:24 +0100 Subject: [PATCH] feat: catch regex pattern matching failure --- src/bb_asset_validation/cli.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/bb_asset_validation/cli.py b/src/bb_asset_validation/cli.py index fce8b6a..b282b12 100644 --- a/src/bb_asset_validation/cli.py +++ b/src/bb_asset_validation/cli.py @@ -40,8 +40,13 @@ def split_path(path): return split_path def get_path_components(asset_path: str): - pattern = re.compile(r"(?P/shows/(?P\S*?)/\S*?/(?P\S*?)/(?P\S*?)_v(?P\S*?)/(?P\S*?)/\S*?/(?P\S*?)_v(?P\d*)\D*?(?P\d*)\D*?\.(?P\w*)\Z)") + regex_pattern = r"(?P/shows/(?P\S*?)/\S*?/(?P\S*?)/(?P\S*?)_v(?P\S*?)/(?P\S*?)/\S*?/(?P\S*?)_v(?P\d*)\D*?(?P\d*)\D*?\.(?P\w*)\Z)" + pattern = re.compile(regex_pattern) match = pattern.match(asset_path) + + if(not match): + raise Exception("Regex pattern matching failed. This is likely due to one of your paths using the incorrect schema.") + path_components = match.groupdict() return path_components