amoghrajesh commented on code in PR #57354:
URL: https://github.com/apache/airflow/pull/57354#discussion_r2469315975


##########
task-sdk/src/airflow/sdk/execution_time/task_runner.py:
##########
@@ -1224,67 +1220,29 @@ def _get_email_subject_content(
         'Mark success: <a href="{{ti.mark_success_url}}">Link</a><br>'
     )
 
-    default_html_content_err = (
-        "Try {{try_number}} out of {{max_tries + 1}}<br>"
-        "Exception:<br>Failed attempt to attach error logs<br>"
-        'Log: <a href="{{ti.log_url}}">Link</a><br>'
-        "Host: {{ti.hostname}}<br>"
-        'Mark success: <a href="{{ti.mark_success_url}}">Link</a><br>'
-    )
-
-    additional_context: dict[str, Any] = {
-        "exception": exception,
+    # Add exception_html to context for template rendering
+    exception_html = str(error).replace("\n", "<br>")

Review Comment:
   Good call.
   
   I am going to use html.escape to try and fix that so that no exceptions 
raise things that can be malicious.
   
   ```
   PyDev console: using IPython 9.4.0
   Python 3.13.3 (main, Apr  8 2025, 13:54:08) [Clang 17.0.0 
(clang-1700.0.13.3)] on darwin
   error = Exception("Error in <strong>query</strong>: SELECT * FROM users")
   earlier = str(error).replace("\n", "<br>")
   earlier
   Out[4]: 'Error in <strong>query</strong>: SELECT * FROM users'
   now = html.escape(str(error)).replace("\n", "<br>")
   now
   Out[8]: 'Error in &lt;strong&gt;query&lt;/strong&gt;: SELECT * FROM users'
   ```



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