{"record":{"id":"eb5e80f846cf092c","repo":"CoplayDev/unity-mcp","slug":"github-returned-a-truncated-directory-tree-incomp","errorCode":null,"errorMessage":"GitHub returned a truncated directory tree (incomplete snapshot). Sync was aborted to prevent accidental deletion of valid local files.","messagePattern":"GitHub returned a truncated directory tree \\(incomplete snapshot\\)\\. Sync was aborted to prevent accidental deletion of valid local files\\.","errorType":"exception","errorClass":"InvalidOperationException","httpStatus":null,"severity":"error","filePath":"MCPForUnity/Editor/Setup/SkillSyncService.cs","lineNumber":192,"sourceCode":"            return true;\n        }\n\n        private static RemoteSnapshot FetchRemoteSnapshot(GitHubRepoInfo repoInfo, string branch, string subdir, Action<string> log)\n        {\n            using var client = CreateGitHubClient();\n            var commitSha = FetchBranchHeadCommitSha(client, repoInfo, branch, log);\n            var treeApiUrl = BuildTreeApiUrl(repoInfo, commitSha);\n            log?.Invoke($\"Fetching remote directory tree at commit {ShortCommit(commitSha)}...\");\n            var json = DownloadString(client, treeApiUrl);\n            var treeResponse = JsonUtility.FromJson<GitHubTreeResponse>(json);\n            if (treeResponse == null || treeResponse.tree == null)\n            {\n                throw new InvalidOperationException(\"Failed to parse GitHub directory tree response.\");\n            }\n\n            if (treeResponse.truncated)\n            {\n                throw new InvalidOperationException(\n                    \"GitHub returned a truncated directory tree (incomplete snapshot). \" +\n                    \"Sync was aborted to prevent accidental deletion of valid local files.\");\n            }\n\n            var normalizedSubdir = NormalizeRemotePath(subdir);\n            var subdirPrefix = string.IsNullOrEmpty(normalizedSubdir) ? string.Empty : $\"{normalizedSubdir}/\";\n            var remoteFiles = new Dictionary<string, string>(StringComparer.Ordinal);\n\n            foreach (var entry in treeResponse.tree)\n            {\n                if (!string.Equals(entry.type, \"blob\", StringComparison.Ordinal))\n                {\n                    continue;\n                }\n\n                var remotePath = NormalizeRemotePath(entry.path);\n                if (string.IsNullOrEmpty(remotePath))\n                {","sourceCodeStart":174,"sourceCodeEnd":210,"githubUrl":"https://github.com/CoplayDev/unity-mcp/blob/c21bf496bca87d54e75bad048563c3adb1782081/MCPForUnity/Editor/Setup/SkillSyncService.cs#L174-L210","documentation":"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.","triggerScenarios":"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).","commonSituations":"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.","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."],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":["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."],"tags":["github","api","safety","limits"],"backgroundTag":null,"analyzedSha":"c21bf496bca87d54e75bad048563c3adb1782081","analyzedAt":"2026-08-13T17:36:56.095Z","schemaVersion":2},"datasetVersion":"2026-08-13T19:17:28.613Z"}