Catch exception when regex in LPR format field is invalid (#20099)

This commit is contained in:
Josh Hawkins 2025-09-16 07:41:25 -05:00 committed by GitHub
parent 5f34a18905
commit 975c8485f9
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -385,11 +385,18 @@ class LicensePlateProcessingMixin:
)
continue
if self.lpr_config.format and not re.fullmatch(
self.lpr_config.format, plate
):
logger.debug(f"Filtered out '{plate}' due to format mismatch")
continue
if self.lpr_config.format:
try:
if not re.fullmatch(self.lpr_config.format, plate):
logger.debug(
f"Filtered out '{plate}' due to format mismatch"
)
continue
except re.error:
# Skip format filtering if regex is invalid
logger.error(
f"{camera}: Invalid regex in LPR format configuration: {self.lpr_config.format}"
)
filtered_data.append((plate, conf_list, area))