jscheffl commented on code in PR #59999:
URL: https://github.com/apache/airflow/pull/59999#discussion_r2659846193
##########
task-sdk/src/airflow/sdk/execution_time/task_runner.py:
##########
@@ -138,6 +137,34 @@ class TaskRunnerMarker:
"""Marker for listener hooks, to properly detect from which component they
are called."""
+def truncate_rendered_value(rendered: Union[str, bytes, Sequence], max_length:
int) -> str:
+ """
+ Truncate rendered value with a reasonable minimum length to avoid edge
cases.
+
+ Args:
+ rendered: The rendered value to truncate
+ max_length: The maximum allowed length for the output
+
+ Returns:
+ Truncated string that respects the max_length constraint
+ """
+ # Set a reasonable minimum to avoid complex edge cases with very small
values
+ if max_length < 100:
+ max_length = 100
+
+ prefix = "Truncated. You can change this behaviour in
[core]max_templated_field_length. "
+ suffix = "... "
+
+ available_length = max_length - len(prefix) - len(suffix)
Review Comment:
Same as above.
--
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]