pierrejeambrun commented on code in PR #48239:
URL: https://github.com/apache/airflow/pull/48239#discussion_r2014281347


##########
airflow-core/src/airflow/jobs/triggerer_job_runner.py:
##########
@@ -192,9 +202,22 @@ class TriggerStateChanges(BaseModel):
         finished: list[int] | None = None
 
 
+def get_discriminator_value(v: Any) -> Any:
+    if isinstance(v, dict):
+        return v.get("kind", v.get("type"))
+    return getattr(v, "kind", getattr(v, "type", None))
+
+
 ToTriggerRunner = Annotated[
-    Union[workloads.RunTrigger, messages.CancelTriggers, 
messages.StartTriggerer],
-    Field(discriminator="kind"),
+    Union[
+        Annotated[workloads.RunTrigger, Tag("RunTrigger")],
+        Annotated[messages.CancelTriggers, Tag("CancelTriggersMessage")],
+        Annotated[messages.StartTriggerer, Tag("StartTriggerer")],
+        Annotated[ConnectionResult, Tag("ConnectionResult")],
+        Annotated[VariableResult, Tag("VariableResult")],
+        Annotated[ErrorResponse, Tag("ErrorResponse")],
+    ],
+    Field(discriminator=Discriminator(get_discriminator_value)),

Review Comment:
   I updated the `kind` field to match `type` of other `ConnectionResult` 
`VariableResult` etc...
   
   This way they all share a common discrimanator `type` => could remove the 
custom discrimator function.



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