Dark Mode

Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

[v3-1-test] Respect maximum page limit in API (#60989) #61073

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

Merged
pierrejeambrun merged 1 commit into v3-1-test from backport-2ed3969-v3-1-test
Jan 26, 2026
Merged

[v3-1-test] Respect maximum page limit in API (#60989) #61073

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions airflow-core/src/airflow/api_fastapi/common/parameters.py
View file
Open in desktop
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
from airflow._shared.timezones import timezone
from airflow.api_fastapi.core_api.base import OrmClause
from airflow.api_fastapi.core_api.security import GetUserDep
from airflow.configuration import conf
from airflow.models import Base
from airflow.models.asset import (
AssetAliasModel,
Expand Down Expand Up @@ -99,8 +100,8 @@ def to_orm(self, select: Select) -> Select:
return select.limit(self.value)

@classmethod
def depends(cls, limit: NonNegativeInt = 50) -> LimitFilter:
return cls().set_value(limit)
def depends(cls, limit: NonNegativeInt = conf.getint("api", "page_size")) -> LimitFilter:
return cls().set_value(min(limit, conf.getint("api", "maximum_page_limit")))


class OffsetFilter(BaseParam[NonNegativeInt]):
Expand Down
10 changes: 7 additions & 3 deletions airflow-core/tests/unit/api_fastapi/core_api/routes/public/t est_task_instances.py
View file
Open in desktop
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@

from tests_common.test_utils.api_fastapi import _check_task_instance_note
from tests_common.test_utils.asserts import assert_queries_count
from tests_common.test_utils.config import conf_vars
from tests_common.test_utils.db import (
clear_db_runs,
clear_rendered_ti_fields,
Expand Down Expand Up @@ -785,8 +786,8 @@ def test_offset_limit(self, test_client, one_task_with_many_mapped_tis):
({"order_by": "map_index", "limit": 100}, list(range(100))),
({"order_by": "-map_index", "limit": 100}, list(range(109, 9, -1))),
(
{"order_by": "state", "limit": 108},
list(range(5, 25)) + list(range(25, 110)) + list(range(3)),
{"order_by": "state", "limit": 108}, # Maximum page limit will limit result to 100 items.
list(range(5, 25)) + list(range(25, 105)),
),
(
{"order_by": "-state", "limit": 100},
Expand All @@ -801,6 +802,8 @@ def test_offset_limit(self, test_client, one_task_with_many_mapped_tis):
def test_mapped_instances_order(
self, test_client, session, params, expected_map_indexes, one_task_with_many_mapped_tis
):
from airflow.configuration import conf

with assert_queries_count(4):
response = test_client.get(
"/dags/mapped_tis/dagRuns/run_mapped_tis/taskInstances/task_2/listMapped",
Expand All @@ -810,7 +813,7 @@ def test_mapped_instances_order(
assert response.status_code == 200
body = response.json()
assert body["total_entries"] == 110
assert len(body["task_instances"]) == params["limit"]
assert len(body["task_instances"]) == min(params["limit"], conf.getint("api", "maximum_page_limit"))
assert expected_map_indexes == [ti["map_index"] for ti in body["task_instances"]]

# Ordering of nulls values is DB specific.
Expand All @@ -822,6 +825,7 @@ def test_mapped_instances_order(
({"order_by": "-rendered_map_index", "limit": 100}, [0] + list(range(11, 110)[::-1])), # Desc
],
)
@conf_vars({("api", "maximum_page_limit"): "110"})
def test_rendered_map_index_order(
self, test_client, session, params, expected_map_indexes, one_task_with_many_mapped_tis
):
Expand Down