CoplayDev/unity-mcp · error · InvalidOperationException
GitHub returned a truncated directory tree (incomplete snaps
Error message
GitHub returned a truncated directory tree (incomplete snapshot). Sync was aborted to prevent accidental deletion of valid local files.
What it means
GitHub's recursive tree API sets truncated=true when the tree exceeds its entry/size limits. SkillSyncService aborts the sync on purpose: with an incomplete file list, the deletion phase of ApplyPlan would treat every omitted remote file as a local file to delete, destroying valid files.
Source
Thrown at MCPForUnity/Editor/Setup/SkillSyncService.cs:192
return true;
}
private static RemoteSnapshot FetchRemoteSnapshot(GitHubRepoInfo repoInfo, string branch, string subdir, Action<string> log)
{
using var client = CreateGitHubClient();
var commitSha = FetchBranchHeadCommitSha(client, repoInfo, branch, log);
var treeApiUrl = BuildTreeApiUrl(repoInfo, commitSha);
log?.Invoke($"Fetching remote directory tree at commit {ShortCommit(commitSha)}...");
var json = DownloadString(client, treeApiUrl);
var treeResponse = JsonUtility.FromJson<GitHubTreeResponse>(json);
if (treeResponse == null || treeResponse.tree == null)
{
throw new InvalidOperationException("Failed to parse GitHub directory tree response.");
}
if (treeResponse.truncated)
{
throw new InvalidOperationException(
"GitHub returned a truncated directory tree (incomplete snapshot). " +
"Sync was aborted to prevent accidental deletion of valid local files.");
}
var normalizedSubdir = NormalizeRemotePath(subdir);
var subdirPrefix = string.IsNullOrEmpty(normalizedSubdir) ? string.Empty : $"{normalizedSubdir}/";
var remoteFiles = new Dictionary<string, string>(StringComparer.Ordinal);
foreach (var entry in treeResponse.tree)
{
if (!string.Equals(entry.type, "blob", StringComparison.Ordinal))
{
continue;
}
var remotePath = NormalizeRemotePath(entry.path);
if (string.IsNullOrEmpty(remotePath))
{View on GitHub (pinned to c21bf496bc)
Solutions
- Reduce the number of files under the synced directory.
- Sync a narrower subdirectory if possible.
- Move large/binary assets out of the skill directory.
- If you control the repo, run a tree-size check and prune before syncing.
Defensive patterns
Strategy: validation
Prevention
- Keep the synced directory small; do not sync a monorepo root.
- Monitor repo tree size before syncing.
- Treat truncation as a hard stop, never a partial-sync signal.
When it happens
Trigger: The synced subdirectory (.claude/skills/unity-mcp-skill) or the whole repo tree is large enough that GitHub truncates the recursive listing (typically tens of thousands of entries or a multi-MB response).
Common situations: Monorepo where the skill dir sits alongside huge generated output; the directory accumulated many assets over time; syncing the entire repo tree rather than a narrow subdir.
Related errors
- Failed to parse GitHub directory tree response.
- Failed to resolve branch head commit SHA for: {branch}
- GitHub request failed: {(int)response.StatusCode} {response.
- fal submit returned no request_id: {truncated_response}
- fal {phase} failed (status={res?.Status}): {detail}
AI-assisted analysis of CoplayDev/unity-mcp@c21bf496bc (2026-08-13).
Data as JSON: /api/errors/eb5e80f846cf092c.
Report an issue: GitHub.