Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix bug in previous-successful-dagrun Execution API endpoint #48520

Merged
merged 1 commit into from
Mar 29, 2025

Conversation

kaxil
Copy link
Member

@kaxil kaxil commented Mar 29, 2025

closes #47612

The bug was as mentioned in #48503 where the logical_date of the currrent TI was None.

We should return an empty PrevSuccessfulDagRunResponse() but because we weren't checking for it, the API server failed with:

airflow-core/tests/unit/api_fastapi/execution_api/versions/head/test_task_instances.py:1160: in test_ti_with_none_as_logical_date
    response = client.get(f"/execution/task-instances/{ti.id}/previous-successful-dagrun")
/usr/local/lib/python3.10/site-packages/starlette/testclient.py:465: in get
    return super().get(
...
...
/usr/local/lib/python3.10/site-packages/cadwyn/schema_generation.py:504: in __call__
    return self._original_callable(*args, **kwargs)
airflow-core/src/airflow/api_fastapi/execution_api/routes/task_instances.py:555: in get_previous_successful_dagrun
    DR.logical_date < task_instance.logical_date,
/usr/local/lib/python3.10/site-packages/sqlalchemy/sql/operators.py:368: in __lt__
    return self.operate(lt, other)
/usr/local/lib/python3.10/site-packages/sqlalchemy/orm/attributes.py:322: in operate
    return op(self.comparator, *other, **kwargs)
/usr/local/lib/python3.10/site-packages/sqlalchemy/sql/operators.py:368: in __lt__
    return self.operate(lt, other)
/usr/local/lib/python3.10/site-packages/sqlalchemy/orm/properties.py:426: in operate
    return op(self.__clause_element__(), *other, **kwargs)
/usr/local/lib/python3.10/site-packages/sqlalchemy/sql/operators.py:368: in __lt__
    return self.operate(lt, other)
/usr/local/lib/python3.10/site-packages/sqlalchemy/sql/elements.py:873: in operate
    return op(self.comparator, *other, **kwargs)
/usr/local/lib/python3.10/site-packages/sqlalchemy/sql/operators.py:368: in __lt__
    return self.operate(lt, other)
/usr/local/lib/python3.10/site-packages/sqlalchemy/sql/type_api.py:1379: in operate
    return super(TypeDecorator.Comparator, self).operate(
/usr/local/lib/python3.10/site-packages/sqlalchemy/sql/type_api.py:77: in operate
    return o[0](self.expr, op, *(other + o[1:]), **kwargs)
/usr/local/lib/python3.10/site-packages/sqlalchemy/sql/default_comparator.py:95: in _boolean_compare
    raise exc.ArgumentError(
E   sqlalchemy.exc.ArgumentError: Only '=', '!=', 'is_()', 'is_not()', 'is_distinct_from()', 'is_not_distinct_from()' operators can be used with None/True/False

^ Add meaningful description above
Read the Pull Request Guidelines for more information.
In case of fundamental code changes, an Airflow Improvement Proposal (AIP) is needed.
In case of a new dependency, check compliance with the ASF 3rd Party License Policy.
In case of backwards incompatible changes please leave a note in a newsfragment file, named {pr_number}.significant.rst or {issue_number}.significant.rst, in airflow-core/newsfragments.

@kaxil kaxil requested review from ashb and amoghrajesh as code owners March 29, 2025 00:33
@boring-cyborg boring-cyborg bot added the area:API Airflow's REST/HTTP API label Mar 29, 2025
@tirkarthi
Copy link
Contributor

This should close #47612 which is the relevant bug report

@ashb ashb linked an issue Mar 29, 2025 that may be closed by this pull request
2 tasks
@kaxil kaxil force-pushed the fix-error-dr-prev branch 4 times, most recently from 5b030a1 to cc56217 Compare March 29, 2025 11:50
The bug was as mentioned in apache#48503 where the `logical_date` of the currrent TI was None.

We should return an empty `PrevSuccessfulDagRunResponse()` but because we weren't checking for it, the API server failed with:

```
airflow-core/tests/unit/api_fastapi/execution_api/versions/head/test_task_instances.py:1160: in test_ti_with_none_as_logical_date
    response = client.get(f"/execution/task-instances/{ti.id}/previous-successful-dagrun")
/usr/local/lib/python3.10/site-packages/starlette/testclient.py:465: in get
    return super().get(
...
...
/usr/local/lib/python3.10/site-packages/cadwyn/schema_generation.py:504: in __call__
    return self._original_callable(*args, **kwargs)
airflow-core/src/airflow/api_fastapi/execution_api/routes/task_instances.py:555: in get_previous_successful_dagrun
    DR.logical_date < task_instance.logical_date,
/usr/local/lib/python3.10/site-packages/sqlalchemy/sql/operators.py:368: in __lt__
    return self.operate(lt, other)
/usr/local/lib/python3.10/site-packages/sqlalchemy/orm/attributes.py:322: in operate
    return op(self.comparator, *other, **kwargs)
/usr/local/lib/python3.10/site-packages/sqlalchemy/sql/operators.py:368: in __lt__
    return self.operate(lt, other)
/usr/local/lib/python3.10/site-packages/sqlalchemy/orm/properties.py:426: in operate
    return op(self.__clause_element__(), *other, **kwargs)
/usr/local/lib/python3.10/site-packages/sqlalchemy/sql/operators.py:368: in __lt__
    return self.operate(lt, other)
/usr/local/lib/python3.10/site-packages/sqlalchemy/sql/elements.py:873: in operate
    return op(self.comparator, *other, **kwargs)
/usr/local/lib/python3.10/site-packages/sqlalchemy/sql/operators.py:368: in __lt__
    return self.operate(lt, other)
/usr/local/lib/python3.10/site-packages/sqlalchemy/sql/type_api.py:1379: in operate
    return super(TypeDecorator.Comparator, self).operate(
/usr/local/lib/python3.10/site-packages/sqlalchemy/sql/type_api.py:77: in operate
    return o[0](self.expr, op, *(other + o[1:]), **kwargs)
/usr/local/lib/python3.10/site-packages/sqlalchemy/sql/default_comparator.py:95: in _boolean_compare
    raise exc.ArgumentError(
E   sqlalchemy.exc.ArgumentError: Only '=', '!=', 'is_()', 'is_not()', 'is_distinct_from()', 'is_not_distinct_from()' operators can be used with None/True/False
```
@kaxil kaxil force-pushed the fix-error-dr-prev branch from cc56217 to b009f16 Compare March 29, 2025 12:22
@kaxil kaxil merged commit 25c4b6b into apache:main Mar 29, 2025
88 checks passed
@kaxil kaxil deleted the fix-error-dr-prev branch March 29, 2025 12:59
shubham-pyc pushed a commit to shubham-pyc/airflow that referenced this pull request Apr 2, 2025
…e#48520)

The bug was as mentioned in apache#48503 where the `logical_date` of the currrent TI was None.

We should return an empty `PrevSuccessfulDagRunResponse()` but because we weren't checking for it, the API server failed with:

```
airflow-core/tests/unit/api_fastapi/execution_api/versions/head/test_task_instances.py:1160: in test_ti_with_none_as_logical_date
    response = client.get(f"/execution/task-instances/{ti.id}/previous-successful-dagrun")
/usr/local/lib/python3.10/site-packages/starlette/testclient.py:465: in get
    return super().get(
...
...
/usr/local/lib/python3.10/site-packages/cadwyn/schema_generation.py:504: in __call__
    return self._original_callable(*args, **kwargs)
airflow-core/src/airflow/api_fastapi/execution_api/routes/task_instances.py:555: in get_previous_successful_dagrun
    DR.logical_date < task_instance.logical_date,
/usr/local/lib/python3.10/site-packages/sqlalchemy/sql/operators.py:368: in __lt__
    return self.operate(lt, other)
/usr/local/lib/python3.10/site-packages/sqlalchemy/orm/attributes.py:322: in operate
    return op(self.comparator, *other, **kwargs)
/usr/local/lib/python3.10/site-packages/sqlalchemy/sql/operators.py:368: in __lt__
    return self.operate(lt, other)
/usr/local/lib/python3.10/site-packages/sqlalchemy/orm/properties.py:426: in operate
    return op(self.__clause_element__(), *other, **kwargs)
/usr/local/lib/python3.10/site-packages/sqlalchemy/sql/operators.py:368: in __lt__
    return self.operate(lt, other)
/usr/local/lib/python3.10/site-packages/sqlalchemy/sql/elements.py:873: in operate
    return op(self.comparator, *other, **kwargs)
/usr/local/lib/python3.10/site-packages/sqlalchemy/sql/operators.py:368: in __lt__
    return self.operate(lt, other)
/usr/local/lib/python3.10/site-packages/sqlalchemy/sql/type_api.py:1379: in operate
    return super(TypeDecorator.Comparator, self).operate(
/usr/local/lib/python3.10/site-packages/sqlalchemy/sql/type_api.py:77: in operate
    return o[0](self.expr, op, *(other + o[1:]), **kwargs)
/usr/local/lib/python3.10/site-packages/sqlalchemy/sql/default_comparator.py:95: in _boolean_compare
    raise exc.ArgumentError(
E   sqlalchemy.exc.ArgumentError: Only '=', '!=', 'is_()', 'is_not()', 'is_distinct_from()', 'is_not_distinct_from()' operators can be used with None/True/False
```
nailo2c pushed a commit to nailo2c/airflow that referenced this pull request Apr 4, 2025
…e#48520)

The bug was as mentioned in apache#48503 where the `logical_date` of the currrent TI was None.

We should return an empty `PrevSuccessfulDagRunResponse()` but because we weren't checking for it, the API server failed with:

```
airflow-core/tests/unit/api_fastapi/execution_api/versions/head/test_task_instances.py:1160: in test_ti_with_none_as_logical_date
    response = client.get(f"/execution/task-instances/{ti.id}/previous-successful-dagrun")
/usr/local/lib/python3.10/site-packages/starlette/testclient.py:465: in get
    return super().get(
...
...
/usr/local/lib/python3.10/site-packages/cadwyn/schema_generation.py:504: in __call__
    return self._original_callable(*args, **kwargs)
airflow-core/src/airflow/api_fastapi/execution_api/routes/task_instances.py:555: in get_previous_successful_dagrun
    DR.logical_date < task_instance.logical_date,
/usr/local/lib/python3.10/site-packages/sqlalchemy/sql/operators.py:368: in __lt__
    return self.operate(lt, other)
/usr/local/lib/python3.10/site-packages/sqlalchemy/orm/attributes.py:322: in operate
    return op(self.comparator, *other, **kwargs)
/usr/local/lib/python3.10/site-packages/sqlalchemy/sql/operators.py:368: in __lt__
    return self.operate(lt, other)
/usr/local/lib/python3.10/site-packages/sqlalchemy/orm/properties.py:426: in operate
    return op(self.__clause_element__(), *other, **kwargs)
/usr/local/lib/python3.10/site-packages/sqlalchemy/sql/operators.py:368: in __lt__
    return self.operate(lt, other)
/usr/local/lib/python3.10/site-packages/sqlalchemy/sql/elements.py:873: in operate
    return op(self.comparator, *other, **kwargs)
/usr/local/lib/python3.10/site-packages/sqlalchemy/sql/operators.py:368: in __lt__
    return self.operate(lt, other)
/usr/local/lib/python3.10/site-packages/sqlalchemy/sql/type_api.py:1379: in operate
    return super(TypeDecorator.Comparator, self).operate(
/usr/local/lib/python3.10/site-packages/sqlalchemy/sql/type_api.py:77: in operate
    return o[0](self.expr, op, *(other + o[1:]), **kwargs)
/usr/local/lib/python3.10/site-packages/sqlalchemy/sql/default_comparator.py:95: in _boolean_compare
    raise exc.ArgumentError(
E   sqlalchemy.exc.ArgumentError: Only '=', '!=', 'is_()', 'is_not()', 'is_distinct_from()', 'is_not_distinct_from()' operators can be used with None/True/False
```
simonprydden pushed a commit to simonprydden/airflow that referenced this pull request Apr 8, 2025
…e#48520)

The bug was as mentioned in apache#48503 where the `logical_date` of the currrent TI was None.

We should return an empty `PrevSuccessfulDagRunResponse()` but because we weren't checking for it, the API server failed with:

```
airflow-core/tests/unit/api_fastapi/execution_api/versions/head/test_task_instances.py:1160: in test_ti_with_none_as_logical_date
    response = client.get(f"/execution/task-instances/{ti.id}/previous-successful-dagrun")
/usr/local/lib/python3.10/site-packages/starlette/testclient.py:465: in get
    return super().get(
...
...
/usr/local/lib/python3.10/site-packages/cadwyn/schema_generation.py:504: in __call__
    return self._original_callable(*args, **kwargs)
airflow-core/src/airflow/api_fastapi/execution_api/routes/task_instances.py:555: in get_previous_successful_dagrun
    DR.logical_date < task_instance.logical_date,
/usr/local/lib/python3.10/site-packages/sqlalchemy/sql/operators.py:368: in __lt__
    return self.operate(lt, other)
/usr/local/lib/python3.10/site-packages/sqlalchemy/orm/attributes.py:322: in operate
    return op(self.comparator, *other, **kwargs)
/usr/local/lib/python3.10/site-packages/sqlalchemy/sql/operators.py:368: in __lt__
    return self.operate(lt, other)
/usr/local/lib/python3.10/site-packages/sqlalchemy/orm/properties.py:426: in operate
    return op(self.__clause_element__(), *other, **kwargs)
/usr/local/lib/python3.10/site-packages/sqlalchemy/sql/operators.py:368: in __lt__
    return self.operate(lt, other)
/usr/local/lib/python3.10/site-packages/sqlalchemy/sql/elements.py:873: in operate
    return op(self.comparator, *other, **kwargs)
/usr/local/lib/python3.10/site-packages/sqlalchemy/sql/operators.py:368: in __lt__
    return self.operate(lt, other)
/usr/local/lib/python3.10/site-packages/sqlalchemy/sql/type_api.py:1379: in operate
    return super(TypeDecorator.Comparator, self).operate(
/usr/local/lib/python3.10/site-packages/sqlalchemy/sql/type_api.py:77: in operate
    return o[0](self.expr, op, *(other + o[1:]), **kwargs)
/usr/local/lib/python3.10/site-packages/sqlalchemy/sql/default_comparator.py:95: in _boolean_compare
    raise exc.ArgumentError(
E   sqlalchemy.exc.ArgumentError: Only '=', '!=', 'is_()', 'is_not()', 'is_distinct_from()', 'is_not_distinct_from()' operators can be used with None/True/False
```
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area:API Airflow's REST/HTTP API
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Dagrun with null logical date results in task-sdk API error
3 participants