uranusjr commented on a change in pull request #20435:
URL: https://github.com/apache/airflow/pull/20435#discussion_r772961071
##########
File path: airflow/models/dagrun.py
##########
@@ -939,14 +939,27 @@ def schedule_tis(self, schedulable_tis: Iterable[TI],
session: Session = NEW_SES
return count
@provide_session
- def get_log_filename_template(self, *, session: Session = NEW_SESSION) ->
Optional[str]:
- if self.log_filename_id is None: # DagRun created before LogFilename
introduction.
- template =
session.query(LogFilename.template).order_by(LogFilename.id).limit(1).scalar()
+ def get_log_filename_template(self, *, session: Session = NEW_SESSION) ->
str:
+ if self.log_template_id is None: # DagRun created before LogTemplate
introduction.
+ template =
session.query(LogTemplate.filename).order_by(LogTemplate.id).limit(1).scalar()
else:
- template =
session.query(LogFilename.template).filter_by(id=self.log_filename_id).scalar()
+ template =
session.query(LogTemplate.filename).filter_by(id=self.log_template_id).scalar()
if template is None:
raise AirflowException(
- f"No log_filename entry found for ID {self.log_filename_id!r}.
"
+ f"No log_template entry found for ID {self.log_template_id!r}.
"
+ f"Please make sure you set up the metadatabase correctly."
Review comment:
This can never happen because 1. `None` has special meaning, and 2.
there’s a foreign key constraint so the database guanratees any non-null value
points to something. Things are going very wrong if we reach this code, so I
think it’s better to fail extremely loudly.
--
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]