Skip to content

fix(hf): follow pagination when listing repository files - #1324

Merged
amisevsk merged 1 commit into
kitops-ml:mainfrom
vedant21-oss:fix/hf-tree-pagination
Nov 20, 2026
Merged

amisevsk merged 1 commit into
kitops-ml:mainfrom
vedant21-oss:fix/hf-tree-pagination

Conversation

@vedant21-oss

@vedant21-oss vedant21-oss commented Nov 19, 2026 •

Copy link
Copy Markdown
Contributor

Description

the hugging face tree api returns at most 1000 entries per request and links to the next page with a Link: <...>; rel="next" header. walkRepoTree only read the first page, so folders with more than 1000 files were silently cut off on kit import.

this keeps requesting pages until there's no next link. the request code moved into a small fetchTreePage helper so the loop stays readable. the next link has to be on the same host as the current page, since the request carries the hf token, and a link pointing back at the same page is treated as an error so it can't loop forever.

tests: a two page httptest server (including a paginated subfolder), plus cases for parsing the Link header. the pagination test fails on main. i also checked against the real api: for allenai/c4, multilingual now lists 59410 files instead of 1000.

Linked issues

fixes #1323

The Hugging Face tree API returns at most 1000 entries per request and
links to the next page in the Link header. walkRepoTree only read the
first page, so folders with more than 1000 files were silently cut off
on import. Keep requesting pages until there is no next link.

Fixes kitops-ml#1323

Signed-off-by: vedant21-oss <vedantmalodeofficial@gmail.com>
@amisevsk

Copy link
Copy Markdown
Contributor

Good catch, I hadn't noticed this 👍

@amisevsk
amisevsk merged commit f16e4fe into kitops-ml:main Nov 20, 2026
8 checks passed
@vedant21-oss

Copy link
Copy Markdown
Contributor Author

thanks! glad it helped

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

kit import from hugging face only gets the first 1000 files in a folder

2 participants