francescomucio commented on code in PR #25509:
URL: https://github.com/apache/airflow/pull/25509#discussion_r938483844


##########
airflow/models/dag.py:
##########
@@ -522,17 +522,35 @@ def __init__(
         self.has_on_success_callback = self.on_success_callback is not None
         self.has_on_failure_callback = self.on_failure_callback is not None
 
-        self.doc_md = doc_md
-
         self._access_control = 
DAG._upgrade_outdated_dag_access_control(access_control)
         self.is_paused_upon_creation = is_paused_upon_creation
 
         self.jinja_environment_kwargs = jinja_environment_kwargs
         self.render_template_as_native_obj = render_template_as_native_obj
+
+        self.doc_md = self.get_doc_md(doc_md)
+
         self.tags = tags or []
         self._task_group = TaskGroup.create_root(self)
         self.validate_schedule_and_params()
 
+    def get_doc_md(self, doc_md: str) -> str:
+        if doc_md is None:
+            return doc_md
+
+        env = self.get_template_env(force_sandboxed=False)
+
+        if not doc_md.endswith('.md'):

Review Comment:
   I trying to trigger a similar error with the PG operator with a query ending 
with `.sql`
   <img width="694" alt="image" 
src="https://user-images.githubusercontent.com/3058143/183014884-85793dd2-b734-4d57-9f96-7ab9f6558680.png";>
   
   Would it make sense to return an error message in the doc, something like:
   
   doc_md = f""""
   # Templating Error!
   Not able to find the template file: {doc_md}.
   """



-- 
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