Eason09053360 opened a new pull request, #73373: URL: https://github.com/apache/airflow/pull/73373
## Why `dry_run=True` is the Task SDK's documented way to run or debug a task locally without an API server. It has been broken for a long time: `noop_handler`'s hand-written `dag_run` payload has not changed since the Task SDK became its own distribution, while the generated `DagRun` model gained five required fields (`data_interval_start`, `data_interval_end`, `end_date`, `state`, `partition_key`). `task_instances.start()` raises a `ValidationError` on the first call, and the supervisor then kills the child process it has already forked. ```python Client(base_url=None, dry_run=True, token="").task_instances.start(uuid7(), 1234, datetime.now(tz=timezone.utc)) # pydantic_core._pydantic_core.ValidationError: 5 validation errors for TIRunContext ``` ## What `noop_handler` serves a `TIRunContext` built from the generated models instead of a literal dict, so the next required field added to `DagRun` fails `mypy-task-sdk` at the definition rather than surfacing at runtime under `dry_run`. `TestClient::test_dry_run` is an existing test this PR rewrites, so it is worth saying why: it compared the payload against a hand-copied duplicate of itself and fetched it with `client.get()`, never reaching `TIRunContext.model_validate_json()`. That is how the drift shipped — the test passes on `main` with the bug live. It now goes through `task_instances.start()` and fails without the fix. Also drops a duplicate `datetime` import in the `TYPE_CHECKING` block that `ruff` flags (`TC004`) once `datetime` is used at runtime. No newsfragment — developer-facing debug aid. ### How to test `uv run --project task-sdk pytest task-sdk/tests/task_sdk/api/test_client.py -k dry_run` --- ##### Was generative AI tooling used to co-author this PR? - [X] Yes — Claude Code (Opus 5) Generated-by: Claude Code (Opus 5) following [the guidelines](https://github.com/apache/airflow/blob/main/contributing-docs/05_pull_requests.rst#gen-ai-assisted-contributions) -- 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]
