You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airflow.apache.org by "hussein-awala (via GitHub)" <gi...@apache.org> on 2023/03/01 21:01:41 UTC

[GitHub] [airflow] hussein-awala commented on a diff in pull request #29821: Add a check for not templateable fields

hussein-awala commented on code in PR #29821:
URL: https://github.com/apache/airflow/pull/29821#discussion_r1122294609


##########
airflow/serialization/serialized_objects.py:
##########
@@ -770,8 +772,12 @@ def _serialize_node(cls, op: BaseOperator | MappedOperator, include_deps: bool)
 
         # Store all template_fields as they are if there are JSON Serializable
         # If not, store them as strings
+        # And raise an exception if the field is not templateable
+        forbidden_fields = set(inspect.signature(BaseOperator.__init__).parameters.keys())
         if op.template_fields:
             for template_field in op.template_fields:
+                if template_field in forbidden_fields:
+                    raise AirflowException(f"Cannot use {template_field} as template field")

Review Comment:
   I updated the exception message to `Cannot template BaseOperator fields: {template_field}`, do you have another suggestion?



-- 
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: commits-unsubscribe@airflow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org