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


##########
airflow-core/src/airflow/serialization/helpers.py:
##########
@@ -28,6 +28,23 @@
 if TYPE_CHECKING:
     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(prefix):
+        return rendered[:max_length]
+
+    available = max_length - len(prefix) - len(suffix)
+    if available <= 0:
+        return rendered[:max_length]
+
+    return f"{prefix}{rendered[:available]!r}{suffix}"

Review Comment:
   While this is good, from a user perspective, if max_length is set to 1, it 
would just display `rendered[0]`. I think from a user perspective, we should 
prioritise communication to user over "correctness". Or the user wont know what 
happened.
   
   Always better to present problem + solution vs misleading partial result ig



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