Taragolis commented on code in PR #28777:
URL: https://github.com/apache/airflow/pull/28777#discussion_r1064227851


##########
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:
   Well, `DagBag` it is definitely not a part of public interface and intend by 
use in plugins and by users as well as manually call `DAG.create_dagrun` 
outside of the tests, the only one operator directly use it is SubDagOperator, 
which deprecated and will be remove in Airflow 3
   
   The general usage of the DAG is create DAG object and assign it by one of 
the [available 
way](https://airflow.apache.org/docs/apache-airflow/stable/concepts/dags.html#dag-assignment).
   
   For run DAG user could use REST API/CLI/TriggerDagRunOperator/Scheduler, all 
other ways is not documented and definitely not recommended. I found same issue 
when TriggerDagRunOperator supported send non-json serialisable data to `conf`, 
and solution was ban this ability, see 
https://github.com/apache/airflow/issues/13414
   
   Not all methods/functions/classes have `_` in the beginning but it doesn't 
mean that this methods could directly call by programmatic way. Best example is 
`execute` method of `BaseOperator` which only intend to use by 
Scheduler/Executor.
   
   There is also PR https://github.com/apache/airflow/pull/28300 which prepare 
info about public Airflow interface, I would suggest clarifying about usage 
some part of airflow (DagBag, DAG.create_dagrun) in that PR because it might 
help to cover more grey zones.



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