ashb commented on a change in pull request #16786:
URL: https://github.com/apache/airflow/pull/16786#discussion_r665240220



##########
File path: airflow/models/xcom.py
##########
@@ -223,7 +223,9 @@ def serialize_value(value: Any):
         if conf.getboolean('core', 'enable_xcom_pickling'):
             return pickle.dumps(value)
         try:
-            return json.dumps(value).encode('UTF-8')
+            from airflow.serialization.serialized_objects import 
BaseSerialization
+
+            return json.dumps(BaseSerialization._serialize(value, 
fail_on_error=True)).encode('UTF-8')

Review comment:
       Oh, excetp:
   
   ```python
       @classmethod
       def to_json(cls, var: Union[DAG, BaseOperator, dict, list, set, tuple]) 
-> str:
           """Stringifies DAGs and operators contained by var and returns a 
JSON string of var."""
           return json.dumps(cls.to_dict(var), ensure_ascii=True)
   
       @classmethod
       def to_dict(cls, var: Union[DAG, BaseOperator, dict, list, set, tuple]) 
-> dict:
           """Stringifies DAGs and operators contained by var and returns a 
dict of var."""
           # Don't call on this class directly - only SerializedDAG or
           # SerializedBaseOperator should be used as the "entrypoint"
           raise NotImplementedError()
   
   ```




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