Alwaysgaurav1 opened a new pull request, #69553:
URL: https://github.com/apache/airflow/pull/69553
### Description
The `GET /execution/xcoms/{dag_id}/{run_id}/{task_id}/{key}/slice` endpoint
translates Python-style slicing into SQLAlchemy `.slice(start, stop)` calls.
However, when `start >= 0` and `stop < 0` (or vice versa), the `stop` value is
adjusted using the total count of rows. After this adjustment, the bounds can
"cross" (i.e., `stop <= start` for forward slices), resulting in a negative
`LIMIT` value being passed to the database — which either returns wrong rows or
causes a database error.
### Fix
This PR adds explicit guards after the count-based adjustment in both the
`start >= 0` and `start < 0` branches:
- If the adjusted bounds have crossed for a forward slice (`step >= 0` and
`stop <= start`), return an empty list immediately.
- If the adjusted bounds have crossed for a reverse slice (`step < 0` and
`start < stop`), return an empty list immediately.
This matches standard Python slice behavior where crossed bounds produce an
empty sequence (e.g., `[1,2,3][5:2] == []`).
All 18 existing slice tests continue to pass.
Closes: #69204
--
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]