Jeevankumar-s commented on code in PR #59882:
URL: https://github.com/apache/airflow/pull/59882#discussion_r2652347233
##########
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:
Thanks for pointing this out.
I agree that showing just a single character can be confusing from a user
perspective.
I’ll update the logic so that, even for very small
`max_templated_field_length` values, we prioritize clearly communicating that
truncation has occurred rather than returning a misleading partial result.
I’ll also apply the same change in the runtime path (task_runner.py) so the
behavior stays consistent.
I’ll push an update shortly.
--
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]