From 79da21bc30b6781bf4a6a435593b23b4f0ceab42 Mon Sep 17 00:00:00 2001 From: Kian Eliasi Date: Mon, 8 Aug 2022 13:11:44 +0430 Subject: [PATCH] Fix the errors raised when None is passed to template filters --- airflow/templates.py | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/airflow/templates.py b/airflow/templates.py index 6ec010f618fd3..4dcd59a291638 100644 --- a/airflow/templates.py +++ b/airflow/templates.py @@ -45,23 +45,28 @@ class SandboxedEnvironment(_AirflowEnvironmentMixin, jinja2.sandbox.SandboxedEnv def ds_filter(value): - return value.strftime('%Y-%m-%d') + if value is not None: + return value.strftime('%Y-%m-%d') def ds_nodash_filter(value): - return value.strftime('%Y%m%d') + if value is not None: + return value.strftime('%Y%m%d') def ts_filter(value): - return value.isoformat() + if value is not None: + return value.isoformat() def ts_nodash_filter(value): - return value.strftime('%Y%m%dT%H%M%S') + if value is not None: + return value.strftime('%Y%m%dT%H%M%S') def ts_nodash_with_tz_filter(value): - return value.isoformat().replace('-', '').replace(':', '') + if value is not None: + return value.isoformat().replace('-', '').replace(':', '') FILTERS = {