pierrejeambrun commented on code in PR #48239:
URL: https://github.com/apache/airflow/pull/48239#discussion_r2016324479
##########
task-sdk/src/airflow/sdk/execution_time/comms.py:
##########
@@ -143,7 +143,7 @@ def from_xcom_response(cls, xcom_response: XComResponse) ->
XComResult:
XComResponse is autogenerated from the API schema, so we need to
convert it to XComResult
for communication between the Supervisor and the task process.
"""
- return cls(**xcom_response.model_dump())
+ return cls(**xcom_response.model_dump(exclude_defaults=True),
type="XComResult")
Review Comment:
The way we convert results from response will not show `type` and get a
deserialization error on the other hand, basically the step
`xcom_result.model_dump_json(exclude_unset=True)` will leave out the `type`
props
```python
elif isinstance(msg, GetConnection):
conn = self.client.connections.get(msg.conn_id)
if isinstance(conn, ConnectionResponse):
conn_result = ConnectionResult.from_conn_response(conn)
resp = conn_result.model_dump_json(exclude_unset=True,
by_alias=True).encode()
else:
resp = conn.model_dump_json().encode()
elif isinstance(msg, GetVariable):
var = self.client.variables.get(msg.key)
if isinstance(var, VariableResponse):
var_result = VariableResult.from_variable_response(var)
resp =
var_result.model_dump_json(exclude_unset=True).encode()
else:
resp = var.model_dump_json().encode()
elif isinstance(msg, GetXCom):
xcom = self.client.xcoms.get(msg.dag_id, msg.run_id,
msg.task_id, msg.key, msg.map_index)
if isinstance(xcom, XComResponse):
xcom_result = XComResult.from_xcom_response(xcom)
resp =
xcom_result.model_dump_json(exclude_unset=True).encode()
else:
resp = xcom.model_dump_json().encode()
```
--
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]