Ajay9704 commented on PR #59999:
URL: https://github.com/apache/airflow/pull/59999#issuecomment-3703799683
@jscheffl Thanks for the valuble feedback, you're absolutely right that I
was overcomplicating things. I think the best approach is to keep it simple by
setting a reasonable minimum (like 100 chars) as you suggested.
I'm planning to implement this simpler approach with a function like this:
```python
def truncate_rendered_value(rendered: str, max_length: int) -> str:
"""Simple truncation with reasonable minimum."""
if max_length < 100: # Set a reasonable minimum
max_length = 100 # Don't allow unreasonably small values
prefix = "Truncated. You can change this behaviour in
[core]max_templated_field_length. "
suffix = "... "
available_length = max_length - len(prefix) - len(suffix)
if available_length <= 0:
return (prefix + suffix)[:max_length]
content_length = max(0, available_length)
content_part = rendered[:content_length]
return f"{prefix}{repr(content_part)}{suffix}"
This keeps the logic straightforward while addressing the core issue ,one
thing I want to make sure does this approach properly handle the edge cases we
might encounter, or should I consider any specific scenarios? I want to ensure
we're not introducing any potential issues while simplifying the solution.
Would this simpler approach work for you? I'll implement it directly in each
file to avoid the shared module complexity.
--
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]