You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airflow.apache.org by ep...@apache.org on 2023/10/29 22:40:25 UTC

(airflow) 33/44: Fix usage of cron-descriptor since BC in v1.3.0 (#34836)

This is an automated email from the ASF dual-hosted git repository.

ephraimanierobi pushed a commit to branch v2-7-test
in repository https://gitbox.apache.org/repos/asf/airflow.git

commit 66def301b1907d9386f26d2602d3ad1ffa7c49c6
Author: Quentin Bray <br...@gmail.com>
AuthorDate: Thu Oct 19 19:07:50 2023 +0200

    Fix usage of cron-descriptor since BC in v1.3.0 (#34836)
    
    When using a custom TimeTable that doesn't provide a CRON expression summary (e.g. : 'Custom TimeTable Plugin'),
    and if the web UI has not yet load the TimeTable when deserializing the DAG,
    accessing the grid view will try to parse the custom description as a CRON expression and then cron-descriptor, that introduce a breaking change in v1.3.0 that now calls 'parse' in the ctor of ExpressionDescriptor raise the FormatException outside of the try block
    
    (working great in Airflow v2.4.2 that uses cron-descriptor v1.2.x)
    
    C.f. : https://github.com/Salamek/cron-descriptor/commit/ec9ea4de2533ebacb0b527cb88973992858910f4
    
    (cherry picked from commit ec6d945aa31af30726d8affaa8b30af330da1085)
---
 airflow/timetables/_cron.py | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/airflow/timetables/_cron.py b/airflow/timetables/_cron.py
index 6787628888..f9b8efa465 100644
--- a/airflow/timetables/_cron.py
+++ b/airflow/timetables/_cron.py
@@ -59,10 +59,10 @@ class CronMixin:
             timezone = Timezone(timezone)
         self._timezone = timezone
 
-        descriptor = ExpressionDescriptor(
-            expression=self._expression, casing_type=CasingTypeEnum.Sentence, use_24hour_time_format=True
-        )
         try:
+            descriptor = ExpressionDescriptor(
+                expression=self._expression, casing_type=CasingTypeEnum.Sentence, use_24hour_time_format=True
+            )
             # checking for more than 5 parameters in Cron and avoiding evaluation for now,
             # as Croniter has inconsistent evaluation with other libraries
             if len(croniter(self._expression).expanded) > 5: