shivaam opened a new pull request, #74484:
URL: https://github.com/apache/airflow/pull/74484
A Dag written in TypeScript cannot pause and wait for a person yet. Python
Dags can, with
`ApprovalOperator` and `HITLOperator`. This adds `approval(...)` and
`humanInput(...)`, used like
`triggerDagRun`.
The task asks the question and waits in `awaiting_input` without holding a
worker. Once someone
answers in the UI, it continues and passes the answer to the next tasks. It
behaves like the Python
operators: Reject skips or fails, timeouts (`responseTimeout`, in seconds)
with defaults, and
assignees.
## Examples
**Approval:** ask "yes or no" before a step runs.
```ts
const report = dag.task("build_report", async () => ({ version: "1.4" }))();
const signOff = dag.task(
"sign_off",
approval({
subject: ({ report }: { report: { version: string } }) => `Ship release
${report.version}?`,
body: "Changes in this release:\n- Faster parsing\n- New UI",
}),
)({ report });
signOff.before(publish); // Reject skips `publish`
```
The Required Actions tab shows the subject, the body as Markdown, and
Approve / Reject buttons.
**Choice:** let a person pick one or more options, and use the answer in the
next task.
```ts
const picked = dag.task(
"choose_regions",
humanInput({
subject: "Which regions should the rollout reach?",
options: ["us", "eu", "apac"],
multiple: true,
}),
)();
dag.task("deploy", async ({ choice }: { choice: HumanInputResult }) => ({
deployedTo: choice.chosen_options, // ["eu", "apac"]
}))({ choice: picked });
```
The Required Actions tab shows the subject and a multi-select of the options.
## Not included, follow-ups
- Forms (`params`), branching on the answer (`HITLBranchOperator`), and
notifiers.
- A HITL section in the Airflow docs page, after #73875 reorganizes it. The
README covers it for now.
- Separate TypeScript SDK fixes found while testing: `executionTimeout` is
not enforced on TypeScript
tasks, and `schedule: null` is rejected by the types.
- Core Airflow behaviour found while testing, the same for Python Dags:
- an answer sent after a timeout failed the task is reported as
successful, but nothing runs;
- an empty choice shows only "Validation Error";
- the UI does not show who a question is assigned to.
## Verification
- Unit and integration tests.
- End to end on a local Breeze setup: approve, reject (skip and fail),
multiple choice, timeout with
a default, and existing native Dag features (passing values, `dag.if`,
`dag.switch`, task groups,
`triggerDagRun`, retries).
related: #73875
---
##### Was generative AI tooling used to co-author this PR?
- [X] Yes — Claude Code (Opus 5.5)
Generated-by: Claude Code (Opus 5.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]