jablecherman opened a new issue, #66492:
URL: https://github.com/apache/airflow/issues/66492
## Description
When defining a `Param` with `format='time'`, Airflow renders a time picker
in the trigger UI. However, the time picker only provides fields for hours and
minutes — there is no seconds input. This makes it impossible to pass the
`format='time'` validation, because the underlying `jsonschema.FormatChecker`
for the `'time'` format validates the value using `datetime.strptime(instance,
"%H:%M:%S")`, which requires seconds.
Any value produced by the UI picker (e.g. `19:30`) will always fail
validation with a 400 Bad Request.
## Steps to Reproduce
1. Define a DAG param with `format='time'`:
```python
from airflow.sdk import Param
params = {
"cutoff_time": Param(
type="string",
format="time",
description="A time value.",
)
}
```
2. Trigger the DAG from the Airflow UI.
3. Use the rendered time picker to select any time (e.g. 19:30).
4. Submit the trigger form.
## Expected Behavior
The value produced by the UI time picker should pass `format='time'`
validation. Either:
- The time picker should include a seconds field so it produces `HH:MM:SS`,
or
- The `format='time'` FormatChecker should accept `HH:MM` as a valid time
string.
## Actual Behavior
```
400 Bad Request
Invalid input for param cutoff_time: '19:30' is not a 'time'
Failed validating 'format' in schema:
{'type': 'string', 'format': 'time'}
On instance:
'19:30'
```
## Root Cause
The `format='time'` check is delegated to `jsonschema.FormatChecker`, which
for this format calls:
```python
# jsonschema/_format.py
@_checks_drafts(draft3="time", raises=ValueError)
def is_draft3_time(instance: object) -> bool:
if not isinstance(instance, str):
return True
return bool(datetime.strptime(instance, "%H:%M:%S"))
```
This requires seconds (`%H:%M:%S`), but the Airflow UI time picker produces
`HH:MM` with no way to supply seconds.
## Environment
- Apache Airflow (Astronomer Runtime 3.1.7)
- jsonschema 4.23.0
- Python 3.10
--
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]