You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airflow.apache.org by GitBox <gi...@apache.org> on 2023/01/08 17:01:52 UTC

[GitHub] [airflow] hussein-awala commented on a diff in pull request #28777: Fix dag run conf encoding with non-JSON serializable values

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


##########
airflow/www/utils.py:
##########
@@ -133,13 +133,25 @@ def get_mapped_summary(parent_instance, task_instances):
 
 
 def get_dag_run_conf(dag_run_conf: Any) -> tuple[str | None, bool]:
+    class DagRunConfEncoder(json.JSONEncoder):
+        def default(self, obj):
+            if isinstance(obj, bytes):
+                try:
+                    return obj.decode()
+                except Exception:
+                    return str(obj)
+            try:
+                return json.JSONEncoder.default(self, obj)
+            except Exception:
+                return str(obj)

Review Comment:
   This method is only used to show dag run conf dictionary content in Airflow Webserver, but the same content is stored in the database as `PickleType` without any type conversion, and it read and deserialized when we call `dag_run.conf`.
   As long as there are no problems with handling the different types in the conf dict, I think converting binary types to str can solve the UI problem.



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