shivaam opened a new pull request, #74569:
URL: https://github.com/apache/airflow/pull/74569
When someone answers a Human-in-the-loop (HITL) request that has form fields
(`params`), the API server now checks each answer against that field's JSON
Schema before saving it. An invalid answer gets a `400` with the reason, and
the request stays open so it can be corrected and resubmitted.
**Why:** today `PATCH .../hitlDetails` saves `params_input` as given:
- **Python `HITLOperator`:** the value is checked only when the task
resumes, so the answer is accepted and then the task fails.
- **TypeScript SDK HITL tasks (`hitl()` / `approval()`, added in #74484):**
the SDK checks only the keys on resume, so an invalid value reaches the task
code. During that review we agreed the value check should live in the API
server, so every SDK gets it from one place.
**Example:** a field declared as `"replicas": Param(3, type="integer",
minimum=1, maximum=10)`
| Answer | Before | After |
|---|---|---|
| `{"replicas": 5}` | 200 | 200 |
| `{"replicas": 50}` | 200, then the Python task fails on resume, and a TS
task receives `50` | 400: `Invalid input for param replicas: 50 is greater than
the maximum of 10 ...` |
| `{"replicas": "5"}` | 200 | 400: `Invalid input for param replicas: '5' is
not of type 'integer' ...` |
| `{"replicaz": 5}` | 200 | 400: `params_input ['replicaz'] does not match
params ['replicas'].` |
The UI form already blocks most of these (min/max, enum, length, dates)
before submitting. This check catches the rules the form does not enforce, such
as `pattern` and `multipleOf`, and answers sent directly to the API.
- **Shared validation:** the check reuses `SerializedParamsDict.validate()`,
the same validation used for Dag-run `conf`.
- **Params without a schema:** params stored without a schema (older
providers) still accept any value.
- **Testing:** tested live with a Python `HITLOperator` and a TS SDK
`approval()` task, plus answers submitted from the UI with array, object,
boolean and nullable fields.
related: #74484
---
##### 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]