Skip to content

Fix/243 truncated repo tree fallback - #245

Open
envico801 wants to merge 2 commits into
AminoffZ:mainfrom
envico801:fix/243-truncated-repo-tree-fallback
Open

Fix/243 truncated repo tree fallback#245
envico801 wants to merge 2 commits into
AminoffZ:mainfrom
envico801:fix/243-truncated-repo-tree-fallback

Conversation

@envico801

Copy link
Copy Markdown

Fix: Handle GitHub API tree truncation (100k+ files)

This PR fixes an issue where repository sizes are not displayed (or show "...") for very large repositories.

Root cause

The extension relies on the GitHub API endpoint:

/repos/:owner/:repo/git/trees/:sha?recursive=1

However, GitHub enforces a hard limit of 100,000 files per response. When this limit is exceeded:

  • The response is truncated (truncated: true)
  • Large portions of the repository tree are missing
  • Certain directories (depending on alphabetical order) are never returned

Check the official api for more info:

As a result, the extension fails to find files and outputs "...".

This can be reproduced with:


Solution

When a truncated tree is detected, this PR introduces a fallback mechanism:

  • Detect repoInfo.truncated === true

  • Fetch the currently viewed directory using:

    /repos/:owner/:repo/contents/:path
    
  • Inject the returned items into the existing tree

This ensures that visible files in the current directory always have valid size data.


Limitation (Important)

  • Folder sizes may appear as 0 B in truncated repositories

This is expected, since calculating folder sizes would require recursive fetching, which would:

  • Significantly increase API usage
  • Potentially freeze the extension on very large repositories

Changes

  • Added getFallbackDirectoryInfo() in api.ts
  • Integrated fallback logic in updateDOM() in dom-manipulation.ts

Closes #243

Before:

before image

After:

after image

envico801 added 2 commits May 4, 2026 17:19
Add fallback mechanism when GitHub's recursive tree API is truncated
(>100k files). When truncation is detected, the extension now fetches
directory-specific data using the contents endpoint to ensure sizes
are still displayed.

This resolves cases where folders show "..." or no size due to missing
data in truncated API responses.
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.

Doesn't display any sizes or just "..." instead of size

1 participant