Jeevankumar-s commented on code in PR #59882:
URL: https://github.com/apache/airflow/pull/59882#discussion_r2654993835


##########
airflow-core/src/airflow/serialization/helpers.py:
##########
@@ -29,6 +29,28 @@
     from airflow.timetables.base import Timetable as CoreTimetable
 
 
+def _truncate_rendered_value(rendered: str, max_length: int) -> str:
+    if max_length <= 0:
+        return ""
+
+    prefix = "Truncated. You can change this behaviour in 
[core]max_templated_field_length. "
+    suffix = "..."
+
+    if max_length <= len(suffix):
+        return suffix[:max_length]
+
+    if max_length <= len(prefix) + len(suffix):
+        return (prefix + suffix)[:max_length]
+
+    available = max_length - len(prefix) - len(suffix)
+    return f"{prefix}{rendered[:available]}{suffix}"
+
+
+
+def _safe_truncate_rendered_value(rendered: Any, max_length: int) -> str:
+    return _truncate_rendered_value(str(rendered), max_length)

Review Comment:
   Thanks for the examples. I agree and have updated the logic to always 
prioritise the truncation message and avoid partial prefix or value output. The 
results now match the expected outputs you shared.



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