{"record":{"id":"29300e0455a53741","repo":"babalae/better-genshin-impact","slug":"url-29300e","errorCode":null,"errorMessage":"仓库URL不能为空","messagePattern":"仓库URL不能为空","errorType":"validation","errorClass":"ArgumentException","httpStatus":null,"severity":"error","filePath":"BetterGenshinImpact/Core/Script/ScriptRepoUpdater.cs","lineNumber":779,"sourceCode":"\n    public async Task<(string, bool)> UpdateCenterRepoByGit(string repoUrl, CheckoutProgressHandler? onCheckoutProgress)\n    {\n        await _repoWriteLock.WaitAsync();\n        try\n        {\n            return await UpdateCenterRepoByGitCore(repoUrl, onCheckoutProgress);\n        }\n        finally\n        {\n            _repoWriteLock.Release();\n        }\n    }\n\n    private async Task<(string, bool)> UpdateCenterRepoByGitCore(string repoUrl, CheckoutProgressHandler? onCheckoutProgress)\n    {\n        if (string.IsNullOrEmpty(repoUrl))\n        {\n            throw new ArgumentException(\"仓库URL不能为空\", nameof(repoUrl));\n        }\n\n        var repoPath = Path.Combine(ReposPath, GetRepoFolderName(repoUrl));\n        var updated = false;\n\n        // 备份相关变量\n        string? oldRepoJsonContent = null;\n\n        await Task.Run(() =>\n        {\n            Repository? repo = null;\n            try\n            {\n                GlobalSettings.SetOwnerValidation(false);\n                if (!Directory.Exists(repoPath))\n                {\n                    // 如果仓库不存在，执行浅克隆操作\n                    _logger.LogInformation($\"浅克隆仓库: {repoUrl} 到 {repoPath}\");","sourceCodeStart":761,"sourceCodeEnd":797,"githubUrl":"https://github.com/babalae/better-genshin-impact/blob/a7cb36712dcb409be610257d877fcea3597e9d6b/BetterGenshinImpact/Core/Script/ScriptRepoUpdater.cs#L761-L797","documentation":"Thrown by UpdateCenterRepoByGitCore when the repoUrl argument is null or empty. This is a pre-condition guard before performing git clone or fetch operations via LibGit2Sharp. The method operates inside a SemaphoreSlim lock (_repoWriteLock) so the check happens after acquiring the lock.","triggerScenarios":"Calling UpdateCenterRepoByGit(repoUrl, ...) with null, empty string, or whitespace-only repoUrl. This is typically called from higher-level repo update methods that should have validated the URL beforehand.","commonSituations":"A script repository configuration has a missing or blank URL field. A repo.json or settings file references a repository with an empty URL. A UI input field for repository URL was left blank. Programmatic caller didn't validate before invoking.","solutions":["Provide a valid git repository URL (HTTPS or SSH format): 'https://github.com/user/repo.git'.","Validate the URL is non-empty before calling UpdateCenterRepoByGit.","Check the repository configuration source (repo.json, settings) for missing URL fields.","Add a UI-level validation requiring a non-empty URL before triggering repo updates."],"exampleFix":"// before\nawait updater.UpdateCenterRepoByGit(\"\", null);\n// after\nawait updater.UpdateCenterRepoByGit(\"https://github.com/user/repo.git\", null);","handlingStrategy":"validation","validationCode":"if (string.IsNullOrWhiteSpace(repoUrl))\n    throw new ArgumentException(\"Repository URL must not be empty\", nameof(repoUrl));","typeGuard":"static bool IsValidRepoUrl(string url) =>\n    !string.IsNullOrWhiteSpace(url) && Uri.TryCreate(url, UriKind.Absolute, out _);","tryCatchPattern":"try\n{\n    await updater.UpdateCenterRepoByGit(repoUrl, null);\n}\ncatch (ArgumentException ex) when (ex.Message.Contains(\"仓库URL不能为空\"))\n{\n    TaskControl.Logger.LogError(\"Repository URL is empty, skipping update\");\n}","preventionTips":["Validate repository URLs at the UI/configuration layer before invoking git operations.","Provide clear error messages when URL fields are blank in the UI.","Use Uri.TryCreate for URL format validation in addition to non-empty checks."],"tags":["git","repository-management","argument-validation","configuration"],"backgroundTag":null,"analyzedSha":"a7cb36712dcb409be610257d877fcea3597e9d6b","analyzedAt":"2026-08-13T16:44:57.548Z","schemaVersion":2},"datasetVersion":"2026-08-13T19:17:28.613Z"}