Repository navigation
fix(hf): follow pagination when listing repository files - #1324
Merged
Merged
Conversation
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
approved these changes
Nov 20, 2026
Contributor
|
Good catch, I hadn't noticed this 👍 |
Contributor
Author
|
thanks! glad it helped |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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.walkRepoTreeonly read the first page, so folders with more than 1000 files were silently cut off onkit import.this keeps requesting pages until there's no next link. the request code moved into a small
fetchTreePagehelper 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
Linkheader. the pagination test fails on main. i also checked against the real api: forallenai/c4,multilingualnow lists 59410 files instead of 1000.Linked issues
fixes #1323