Sun-Wukhan opened a new pull request, #77597:
URL: https://github.com/apache/airflow/pull/77597

   closes: #77591
   
   `RangeFilter.to_orm` in 
`airflow-core/src/airflow/api_fastapi/common/parameters/range.py` guards each 
bound with a truthiness check (`if self.value.lower_bound_gte:`). A bound of 
`0` or `0.0` is falsy, so it is silently skipped: `GET 
/api/v2/dags/{dag_id}/dagRuns?duration_gte=0` returns unfiltered results, and 
the same applies to `duration_lte=0` and the backfill `max_active_runs` bounds. 
`is_active()` already checks `is not None`, so the filter reports itself active 
while emitting no WHERE clause. `NullableDatetimeRangeFilter.to_orm` has the 
same four guards.
   
   Changes:
   
   * In `RangeFilter.to_orm` and `NullableDatetimeRangeFilter.to_orm`, each of 
the eight bound guards now checks `is not None` instead of truthiness, 
consistent with `is_active()`. Datetime bounds are never falsy in practice, but 
keeping both methods consistent prevents the same bug class.
   
   Tests (in `airflow-core/tests/unit/api_fastapi/common/test_parameters.py`):
   
   * New `TestRangeFilter.test_zero_bound_is_applied` (parametrized): runs a 
`RangeFilter` over an in-memory table with values -1, 0 and 5 and asserts a 
bound of `0` / `0.0` actually filters: `lower_bound_gte=0` keeps [0, 5], 
`lower_bound_gt=0` keeps [5], `upper_bound_lte=0` keeps [-1, 0], 
`upper_bound_lt=0` keeps [-1], and `lower_bound_gte=0.0` with 
`upper_bound_lte=0.0` keeps [0].
   
   Test evidence: the new tests are written for CI. Locally, the changed 
behaviour was verified against the real edited module with a standalone script 
(fail-before: on the unpatched code every 0-bound case returns all rows 
unfiltered and `is_active()` is True while no WHERE clause is emitted; 
pass-after: every case filters correctly and the clause is emitted). 
`NullableDatetimeRangeFilter` output for real datetime bounds is unchanged. 
`ruff format` and `ruff check` pass on both edited files. The full Airflow test 
suite was not run locally.
   
   ---
   
   ##### Was generative AI tooling used to co-author this PR?
   
   - [X] Yes (please specify the tool below)
   
   Generated-by: Muse 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]

Reply via email to