From f8b0746e737e3418b6de4564728c5d867e27cb28 Mon Sep 17 00:00:00 2001 From: lebaudantoine Date: Thu, 12 Mar 2026 14:33:12 +0100 Subject: [PATCH] =?UTF-8?q?=E2=99=BB=EF=B8=8F(backend)=20factorize=20regex?= =?UTF-8?q?=20used=20in=20the=20S3=20event=20parser?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Avoid duplicating patterns that match the same logical unit by sharing common parts between the two regexes. This logical factorization improves maintainability and ensures consistent parsing behavior across S3 event handlers. --- src/backend/core/recording/event/parsers.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/backend/core/recording/event/parsers.py b/src/backend/core/recording/event/parsers.py index 9fb195ed..8398beff 100644 --- a/src/backend/core/recording/event/parsers.py +++ b/src/backend/core/recording/event/parsers.py @@ -9,6 +9,8 @@ from typing import Any, Dict, Optional, Protocol from django.conf import settings from django.utils.module_loading import import_string +from core.enums import FILE_EXT_REGEX, UUID_REGEX + from .exceptions import ( InvalidBucketError, InvalidFilepathError, @@ -86,7 +88,7 @@ class MinioParser: # pylint: disable=line-too-long self._filepath_regex = re.compile( - r"(?P(?:[^%]+%2F)+)?(?P[0-9a-fA-F\-]{36})\.(?P[a-zA-Z0-9]+)" + rf"(?P(?:[^%]+%2F)+)?(?P{UUID_REGEX})\.(?P{FILE_EXT_REGEX})" ) @staticmethod