phanikumv commented on code in PR #67537:
URL: https://github.com/apache/airflow/pull/67537#discussion_r3375280097
##########
airflow-core/src/airflow/models/backfill.py:
##########
@@ -266,6 +298,51 @@ def _get_dag_run_no_create_reason(dr, reprocess_behavior:
ReprocessBehavior) ->
return non_create_reason
+def _validate_partition_window(
+ partition_date_start: datetime | None,
+ partition_date_end: datetime | None,
+) -> None:
+ """Raise ``InvalidPartitionWindow`` when start is strictly after end."""
+ if (
+ partition_date_start is not None
+ and partition_date_end is not None
+ and partition_date_start.date() > partition_date_end.date()
+ ):
+ raise InvalidPartitionWindow(
+ f"partition_date_start ({partition_date_start.date()}) must not be
after "
+ f"partition_date_end ({partition_date_end.date()})."
+ )
+
+
+def _resolve_backfill_window(
Review Comment:
This will cause a regression. This PR's `_resolve_backfill_window` rejects
`from_date`/`to_date` for partitioned Dags by raising
`DateFlagsOnPartitionedDag`, but this route always sends `from_date`/`to_date`
(they're required on `BackfillPostBody`
and partition selectors aren't exposed), so any partitioned-Dag backfill via
the API/UI now hits that exception.
Since it isn't listed in this `except` block and has no `ValueError`
handler, it escapes as an HTTP 500 rather than a 4xx. Since the pre-PR
`_get_info_list` partition branch accepted `from_date`/`to_date` and
partitioned timetables have shipped since 3.2.0.
Please either expose `partition_date_start`/`partition_date_end` on
`BackfillPostBody` and forward them from both routes
([L243](https://github.com/apache/airflow/blob/3391c3850089e6b0d13780fd6443b522d8e4fcb8/airflow-core/src/airflow/api_fastapi/core_api/routes/public/backfills.py#L243-L253)
and
[L298](https://github.com/apache/airflow/blob/3391c3850089e6b0d13780fd6443b522d8e4fcb8/airflow-core/src/airflow/api_fastapi/core_api/routes/public/backfills.py#L298-L306)),
or, if API support is deferred, at least add the
four new exception classes to the `except` blocks
([L272](https://github.com/apache/airflow/blob/3391c3850089e6b0d13780fd6443b522d8e4fcb8/airflow-core/src/airflow/api_fastapi/core_api/routes/public/backfills.py#L272-L280)
and
[L327](https://github.com/apache/airflow/blob/3391c3850089e6b0d13780fd6443b522d8e4fcb8/airflow-core/src/airflow/api_fastapi/core_api/routes/public/backfills.py#L327-L335))
mapped to `RequestValidationError` so it returns
a 422 instead of a 500.
Either way an API-level test for the partitioned case would catch this.
--
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]