amoghrajesh commented on code in PR #59711:
URL: https://github.com/apache/airflow/pull/59711#discussion_r2650528581
##########
task-sdk/src/airflow/sdk/definitions/dag.py:
##########
@@ -1429,17 +1429,22 @@ def _run_task(
ti.task = create_scheduler_operator(taskrun_result.ti.task)
if ti.state == TaskInstanceState.DEFERRED and isinstance(msg,
DeferTask) and run_triggerer:
+ from airflow.sdk.serde import deserialize, serialize
from airflow.utils.session import create_session
# API Server expects the task instance to be in QUEUED state
before
# resuming from deferral.
ti.set_state(TaskInstanceState.QUEUED)
log.info("[DAG TEST] running trigger in line")
- trigger = import_string(msg.classpath)(**msg.trigger_kwargs)
+ # trigger_kwargs need to be deserialized before passing to the
trigger class since they are in serde encoded format
+ kwargs = deserialize(msg.trigger_kwargs) # type:
ignore[type-var] # needed to convince mypy that trigger_kwargs is a dict or a
str because its unable to infer JsonValue
Review Comment:
It was this error:
```python
task-sdk/src/airflow/sdk/definitions/dag.py:1441: error: Value of type
variable "T" of "deserialize" cannot be "Collection[str]" [type-var]
kwargs = deserialize(msg.trigger_kwargs)
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Found 1 error in 1 file (checked 176 source files)
```
##########
airflow-core/tests/unit/api_fastapi/execution_api/versions/head/test_task_instances.py:
##########
@@ -579,8 +581,10 @@ def test_next_kwargs_still_encoded(self, client, session,
create_task_instance,
)
ti.next_method = "execute_complete"
- # ti.next_kwargs under the hood applies the serde encoding for us
- ti.next_kwargs = {"moment": instant}
+ # explicitly serialize using serde before assigning since we use
JSON/JSONB now
+ # this value comes serde serialized from the worker
+ expected_next_kwargs = serialize({"moment": instant})
Review Comment:
Yeah sure
--
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]