jedcunningham commented on code in PR #38094:
URL: https://github.com/apache/airflow/pull/38094#discussion_r1535747980
##########
airflow/config_templates/config.yml:
##########
@@ -492,6 +492,14 @@ core:
type: string
example: ~
default: "Disabled"
+ max_templated_field_size:
+ description: |
+ The maximum size of the rendered template field in bytes. If the value
to be stored in the
Review Comment:
Nit: not bytes, characters.
```suggestion
The maximum length of the rendered template field. If the value to
be stored in the
```
##########
airflow/serialization/helpers.py:
##########
@@ -38,7 +39,19 @@ def is_jsonable(x):
else:
return True
+ max_size = conf.getint("core", "max_templated_field_size")
if not is_jsonable(template_field):
- return str(template_field)
+ serialized = str(template_field)
+ if len(serialized) > max_size:
+ return (
+ "Value removed due to size. "
+ "You can change this behaviour in
[core]max_templated_field_size"
+ )
+ return serialized
else:
+ if template_field and len(str(template_field)) > max_size:
+ return (
+ "Value removed due to size. "
+ "You can change this behaviour in
[core]max_templated_field_size"
+ )
Review Comment:
Since you are always comparing the str length, you don't have to do it in
each branch, you can do it before the if.
--
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]