{"record":{"id":"0494d84d6b10ff32","repo":"babalae/better-genshin-impact","slug":"repo-json","errorCode":null,"errorMessage":"本地仓库缺少 repo.json","messagePattern":"本地仓库缺少 repo\\.json","errorType":"exception","errorClass":"Exception","httpStatus":null,"severity":"error","filePath":"BetterGenshinImpact/Core/Script/ScriptRepoUpdater.cs","lineNumber":1825,"sourceCode":"\n        if (File.Exists(repoJsonPath))\n        {\n            repoJsonDir = CenterRepoPath;\n        }\n        else\n        {\n            // 递归查找 repo.json\n            var localRepoJsonPath = Directory\n                .GetFiles(CenterRepoPath, \"repo.json\", SearchOption.AllDirectories).FirstOrDefault();\n            if (localRepoJsonPath != null)\n            {\n                repoJsonDir = Path.GetDirectoryName(localRepoJsonPath);\n            }\n        }\n\n        if (string.IsNullOrEmpty(repoJsonDir))\n        {\n            throw new Exception(\"本地仓库缺少 repo.json\");\n        }\n\n        // 检查 repo.json 同级是否存在 repo/ 目录来判断仓库类型\n        var repoSubDir = Path.Combine(repoJsonDir, \"repo\");\n        if (Directory.Exists(repoSubDir))\n        {\n            // 存在 repo/ 目录，说明是文件式仓库\n            return repoSubDir;\n        }\n        else\n        {\n            // 不存在 repo/ 目录，说明是 Git 仓库\n            return repoJsonDir;\n        }\n    }\n\n    private (string time, string url, string file) ParseJson(string jsonString)\n    {","sourceCodeStart":1807,"sourceCodeEnd":1843,"githubUrl":"https://github.com/babalae/better-genshin-impact/blob/a7cb36712dcb409be610257d877fcea3597e9d6b/BetterGenshinImpact/Core/Script/ScriptRepoUpdater.cs#L1807-L1843","documentation":"Thrown by FindCenterRepoPath when neither a top-level repo.json nor a recursively-found repo.json exists under CenterRepoPath. The center repo manifest file is mandatory to locate scripts; without it the path cannot be resolved.","triggerScenarios":"FindCenterRepoPath() runs: File.Exists(CenterRepoPath/repo.json) is false, then Directory.GetFiles(CenterRepoPath, \"repo.json\", SearchOption.AllDirectories).FirstOrDefault() returns null, so repoJsonDir stays null.","commonSituations":"First run before any repo has been downloaded; a prior download/clone failed and left no repo.json; the CenterRepoPath directory was deleted or moved; permissions prevent reading the directory; the repo was cloned but HEAD pointed at a commit lacking repo.json (so checkout didn't materialize it).","solutions":["Trigger a fresh download/clone of the center repo before calling FindCenterRepoPath (ensure the manifest exists first).","Verify CenterRepoPath is correct and the directory is readable; check `Directory.Exists(CenterRepoPath)`.","If repo.json exists in the Git tree but wasn't checked out to disk, run CheckoutRepoJson to materialize it before FindCenterRepoPath.","Provide a recovery action in the error: prompt the user to re-download the center repo."],"exampleFix":"// before\nif (string.IsNullOrEmpty(repoJsonDir))\n    throw new Exception(\"本地仓库缺少 repo.json\");\n\n// after (recovery hint + path)\nif (string.IsNullOrEmpty(repoJsonDir))\n    throw new FileNotFoundException(\n        $\"本地仓库缺少 repo.json（搜索目录: {CenterRepoPath}）。请重新下载中央仓库。\",\n        Path.Combine(CenterRepoPath, \"repo.json\"));","handlingStrategy":"validation","validationCode":"// Ensure the manifest is materialized before lookup\nif (!File.Exists(Path.Combine(CenterRepoPath, \"repo.json\")) &&\n    Directory.GetFiles(CenterRepoPath, \"repo.json\", SearchOption.AllDirectories).Length == 0)\n{\n    // trigger download/clone to obtain repo.json\n    await DownloadRepoAndUnzip(centerRepoUrl);\n}","typeGuard":null,"tryCatchPattern":"catch (FileNotFoundException ex) when (ex.Message.Contains(\"repo.json\"))\n{\n    UIDispatcherHelper.Invoke(() => Toast.Error(\"中央仓库未初始化，正在重新下载...\"));\n    await DownloadRepoAndUnzip(centerRepoUrl);\n}","preventionTips":["Download/clone the center repo before FindCenterRepoPath is ever called.","Verify Directory.Exists(CenterRepoPath) and readability.","Run CheckoutRepoJson to materialize the manifest after a Git clone."],"tags":["filesystem","manifest","center-repo","repo-json","precondition"],"backgroundTag":null,"analyzedSha":"a7cb36712dcb409be610257d877fcea3597e9d6b","analyzedAt":"2026-08-13T16:44:57.548Z","schemaVersion":2},"datasetVersion":"2026-08-13T19:17:28.613Z"}