Lee-W commented on code in PR #49164:
URL: https://github.com/apache/airflow/pull/49164#discussion_r2292623452


##########
airflow-core/src/airflow/serialization/serialized_objects.py:
##########
@@ -1932,85 +1932,92 @@ def serialize_dag(cls, dag: SdkDag) -> dict:
     @classmethod
     def deserialize_dag(cls, encoded_dag: dict[str, Any]) -> SerializedDAG:
         """Deserializes a DAG from a JSON object."""
-        if "dag_id" not in encoded_dag:
-            raise RuntimeError(
-                "Encoded dag object has no dag_id key.  You may need to run 
`airflow dags reserialize`."
+        try:
+            if "dag_id" not in encoded_dag:
+                raise RuntimeError(

Review Comment:
   "Looks like" this is the only one that might raise a `RuntimeError` so we 
can have a dedicated try-except here



##########
airflow-core/src/airflow/serialization/serialized_objects.py:
##########
@@ -1932,85 +1932,92 @@ def serialize_dag(cls, dag: SdkDag) -> dict:
     @classmethod
     def deserialize_dag(cls, encoded_dag: dict[str, Any]) -> SerializedDAG:
         """Deserializes a DAG from a JSON object."""
-        if "dag_id" not in encoded_dag:
-            raise RuntimeError(
-                "Encoded dag object has no dag_id key.  You may need to run 
`airflow dags reserialize`."
+        try:
+            if "dag_id" not in encoded_dag:
+                raise RuntimeError(

Review Comment:
   and this can be applied to other blocks that might raise a ValueError or 
KeyError. if the whole blocks might raise such errors. I would suggest making 
this logic a method so it's easier to read



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