Skip to content

Fix airflowctl list pagination when the server caps the page size - #76268

Merged
henry3260 merged 4 commits into
apache:mainfrom
Rishabh00b:fix-airflowctl-pagination-capped-page-limit
Nov 4, 2026
Merged

henry3260 merged 4 commits into
apache:mainfrom
Rishabh00b:fix-airflowctl-pagination-capped-page-limit

Conversation

@Rishabh00b

Copy link
Copy Markdown
Contributor

airflowctl's execute_list moves to the next page by the limit it requested. The server may return fewer entries than that when api.maximum_page_limit is set lower than the client's limit of 50. In that case the entries between the pages are never fetched, and a result smaller than the limit comes back as one short page. Commands such as pools export, dags list and variables list then silently drop data.

This advances by the number of entries actually received and stops on an empty page, so a short or empty page can't cause a wrong offset or an endless loop.

Tests: one where the server caps pages at 2 entries while the client asks for 50, and one for an empty page. Both fail without the change.


Was generative AI tooling used to co-author this PR?
  • Yes (Claude Code)

…the page size

execute_list advanced the offset by the requested limit. When the server
returns fewer entries than requested, because api.maximum_page_limit is
lower than the client's limit, the entries in between were never fetched,
and a collection smaller than the limit was returned as a single short
page. Commands such as pools export, dags list and variables list then
silently dropped data.

Advance by the number of entries actually received and stop on an empty
page.

@Eason09053360 Eason09053360 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the patch! Feel free to resolve it.

The guard that returns the first page when the response model has no
list field was not exercised by any test, so removing it left the suite
green.

@Andrushika Andrushika left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, left few comments

The while loop already stops when the first page is empty or when all
entries were received, so the separate check before it is not needed.
@Andrushika

Andrushika commented Nov 3, 2026 •

Copy link
Copy Markdown
Contributor

We might be able to drop this guard and its test here. As far as I can see, every model that airflowctl passes to execute_list has a list field.

Could you please solve it?

@Andrushika

Copy link
Copy Markdown
Contributor

Also, we might need to update the PR body. Thanks.

@shahar1 shahar1 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Rishabh00b Could you please address Andrew's comments and I'll merge afterwards?

@shahar1 shahar1 left a comment •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM on the fix itself: advancing by the entries actually received is the right cure for a server-side api.maximum_page_limit cap, and I confirmed locally that all three new tests fail on main and pass with the change (195 tests in test_operations.py green). Two nits below, none blocking. On the open question about the found_key is None guard: every model handed to execute_list today has a list field, so the guard only protects a future caller bug that a TypeError would surface anyway — I'd lean towards dropping it and its test to keep the diff to the bug, but either way is fine by me. For whoever merges: execute_list on airflow-ctl/v0-1-test still has the total_entries < limit early return but none of the total_entries is None handling and wraps validation in a local safe_validate, so the backport-to-airflow-ctl/v0-1-test cherry-pick will conflict and needs a manual backport PR.

Smaller observations

  • PR description — Only the test count is stale: the body still describes two tests, while the branch has three after the second commit added the no-entries-list guard test (Andrushika already asked for the body refresh). Whichever way the guard question goes, the body should match the final set.
  • See inline comments on airflow-ctl/tests/airflow_ctl/api/test_operations.py:311.
  • Please address Andrew's comments.

This review was drafted by an AI-assisted tool and
confirmed by an Apache Airflow maintainer. The maintainer
approving this PR has read the findings and signed off. If
something feels off, please reply on the PR and a maintainer
will follow up.

More on how Apache Airflow handles maintainer review:
Contributing guide.

Co-authored-by: Shahar Epstein <[email protected]>
@henry3260
henry3260 enabled auto-merge (squash) November 3, 2026 18:21
@henry3260
henry3260 merged commit 5308480 into apache:main Nov 4, 2026
92 checks passed
@github-actions

github-actions Bot commented Nov 4, 2026

Copy link
Copy Markdown
Contributor

Backport failed to create: airflow-ctl/v0-1-test. View the failure log Run details

Note: As of Merging PRs targeted for Airflow 3.X
the committer who merges the PR is responsible for backporting the PRs that are bug fixes (generally speaking) to the maintenance branches.

In matter of doubt please ask in #release-management Slack channel.

Status Branch Result
❌ airflow-ctl/v0-1-test Commit Link

You can attempt to backport this manually by running:

cherry_picker 5308480 airflow-ctl/v0-1-test

This should apply the commit to the airflow-ctl/v0-1-test branch and leave the commit in conflict state marking
the files that need manual conflict resolution.

After you have resolved the conflicts, you can continue the backport process by running:

cherry_picker --continue

If you don't have cherry-picker installed, see the installation guide.

@Andrushika

Copy link
Copy Markdown
Contributor

@henry3260 would appreciate it if you could help backport this to airflow-ctl/v0-1-test :)

@henry3260

Copy link
Copy Markdown
Member

@henry3260 would appreciate it if you could help backport this to airflow-ctl/v0-1-test :)

Will do thanks 😄

henry3260 added a commit that referenced this pull request Nov 4, 2026
…r caps the page size (#76268) (#76414)

(cherry picked from commit 5308480)

Conflict resolution: this branch validates pages through the local
safe_validate/fill_missing_fields helper instead of validate_response, and it
has no "total_entries is None" guard because that handling is main-only, so the
early return for a short collection is dropped rather than narrowed.

Co-authored-by: Rishabh <[email protected]>
shahar1 pushed a commit to shahar1/airflow that referenced this pull request Nov 4, 2026
…r caps the page size (apache#76268) (apache#76414)

(cherry picked from commit 5308480)

Conflict resolution: this branch validates pages through the local
safe_validate/fill_missing_fields helper instead of validate_response, and it
has no "total_entries is None" guard because that handling is main-only, so the
early return for a short collection is dropped rather than narrowed.

Co-authored-by: Rishabh <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants