potiuk commented on a change in pull request #20482:
URL: https://github.com/apache/airflow/pull/20482#discussion_r774509120



##########
File path: airflow/utils/log/file_task_handler.py
##########
@@ -82,13 +82,15 @@ def _render_filename(self, ti: "TaskInstance", try_number: 
int) -> str:
                 context = Context(ti=ti, 
ts=ti.get_dagrun().logical_date.isoformat())
             context["try_number"] = try_number
             return render_template_to_string(self.filename_jinja_template, 
context)
-
-        return self.filename_template.format(
-            dag_id=ti.dag_id,
-            task_id=ti.task_id,
-            execution_date=ti.get_dagrun().logical_date.isoformat(),
-            try_number=try_number,
-        )
+        elif self.filename_template:
+            return self.filename_template.format(
+                dag_id=ti.dag_id,
+                task_id=ti.task_id,
+                execution_date=ti.get_dagrun().logical_date.isoformat(),
+                try_number=try_number,
+            )
+        else:
+            return ""  # mypy

Review comment:
       The way `parse_template_string` works - it guarantess that either 
`filename_jinja_template` or `filename_template` is set. There is no way both 
will be None. The only "real" case where (currently) the if can be reached is 
if the "template_string" is "". But this is wrong anyway.
   
   I'd say:
   
   * raise RuntimeError in "parse_template_string" if str is ""
   * raise RuntimeError instead of 'return ""'   - with "This should never 
happen" kind of message.
   
    




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


Reply via email to