uranusjr commented on code in PR #38094:
URL: https://github.com/apache/airflow/pull/38094#discussion_r1537110231


##########
airflow/serialization/helpers.py:
##########
@@ -38,7 +40,21 @@ def is_jsonable(x):
         else:
             return True
 
+    max_length = conf.getint("core", "max_templated_field_length")
+
     if not is_jsonable(template_field):
+        if len(str(template_field)) > max_length:
+            rendered = redact(str(template_field), name)
+            return (
+                "Truncated. You can change this behaviour in 
[core]max_templated_field_length. "
+                f"{rendered[:max_length - 79]!r}... "
+            )
         return str(template_field)
     else:
+        if template_field and len(str(template_field)) > max_length:
+            rendered = redact(str(template_field), name)

Review Comment:
   Do we want to use `json.dumps` here?
   
   Also we should reduce the stringify calls (either `str` or `json.dumps`) to 
exactly once for each time this function is called. The call can be expensive.



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