{"record":{"id":"500b1f3c3421c662","repo":"EllanJiang/GameFramework","slug":"download-uri-is-invalid","errorCode":null,"errorMessage":"Download uri is invalid.","messagePattern":"Download uri is invalid\\.","errorType":"exception","errorClass":"GameFrameworkException","httpStatus":null,"severity":"error","filePath":"GameFramework/Download/DownloadManager.cs","lineNumber":403,"sourceCode":"        /// <summary>\n        /// 增加下载任务。\n        /// </summary>\n        /// <param name=\"downloadPath\">下载后存放路径。</param>\n        /// <param name=\"downloadUri\">原始下载地址。</param>\n        /// <param name=\"tag\">下载任务的标签。</param>\n        /// <param name=\"priority\">下载任务的优先级。</param>\n        /// <param name=\"userData\">用户自定义数据。</param>\n        /// <returns>新增下载任务的序列编号。</returns>\n        public int AddDownload(string downloadPath, string downloadUri, string tag, int priority, object userData)\n        {\n            if (string.IsNullOrEmpty(downloadPath))\n            {\n                throw new GameFrameworkException(\"Download path is invalid.\");\n            }\n\n            if (string.IsNullOrEmpty(downloadUri))\n            {\n                throw new GameFrameworkException(\"Download uri is invalid.\");\n            }\n\n            if (TotalAgentCount <= 0)\n            {\n                throw new GameFrameworkException(\"You must add download agent first.\");\n            }\n\n            DownloadTask downloadTask = DownloadTask.Create(downloadPath, downloadUri, tag, priority, m_FlushSize, m_Timeout, userData);\n            m_TaskPool.AddTask(downloadTask);\n            return downloadTask.SerialId;\n        }\n\n        /// <summary>\n        /// 根据下载任务的序列编号移除下载任务。\n        /// </summary>\n        /// <param name=\"serialId\">要移除下载任务的序列编号。</param>\n        /// <returns>是否移除下载任务成功。</returns>\n        public bool RemoveDownload(int serialId)","sourceCodeStart":385,"sourceCodeEnd":421,"githubUrl":"https://github.com/EllanJiang/GameFramework/blob/d0c010b05167c58e92350449d04864a91ca13fd2/GameFramework/Download/DownloadManager.cs#L385-L421","documentation":"GameFramework's DownloadManager.AddDownload throws this when the downloadUri parameter is null or empty. The URI is the remote address of the file to download; without it no task can be queued. It is thrown immediately after the downloadPath check, before the agent-count check.","triggerScenarios":"Calling AddDownload with downloadUri = null or \"\", or with a URI read from an update/version manifest entry that was missing or blank.","commonSituations":"Resource-update server address not configured; version list entry missing a URL field; string concatenation producing an empty URI when CDN base URL is unset.","solutions":["Pass a valid remote URL (e.g. \"http://cdn.example.com/file.dat\") as downloadUri","Validate the URI at the call site with string.IsNullOrEmpty before invoking AddDownload","Verify the source manifest/config that supplies the URI is complete and the CDN base address is set"],"exampleFix":"// before\nstring uri = versionInfo.Url; // may be null/empty\nDownloadManager.AddDownload(downloadPath, uri, tag, priority, userData);\n// after\nif (string.IsNullOrEmpty(versionInfo.Url)) { Log.Warning(\"Missing URL for {0}\", versionInfo.Name); return; }\nDownloadManager.AddDownload(downloadPath, versionInfo.Url, tag, priority, userData);","handlingStrategy":"validation","validationCode":"if (string.IsNullOrEmpty(downloadUri)) throw new ArgumentException(\"downloadUri must be a non-empty URL\", nameof(downloadUri));\nif (!Uri.TryCreate(downloadUri, UriKind.Absolute, out var u) || (u.Scheme != Uri.UriSchemeHttp && u.Scheme != Uri.UriSchemeHttps)) throw new ArgumentException(\"downloadUri is not an absolute http(s) URL\");","typeGuard":"static bool IsValidDownloadUri(string uri) => !string.IsNullOrEmpty(uri) && Uri.TryCreate(uri, UriKind.Absolute, out var u) && (u.Scheme == Uri.UriSchemeHttp || u.Scheme == Uri.UriSchemeHttps);","tryCatchPattern":"try { downloadManager.AddDownload(path, uri, tag, priority, userData); } catch (GameFrameworkException ex) when (ex.Message == \"Download uri is invalid.\") { Log.Error(\"Invalid download uri for {0}\", path); }","preventionTips":["Sanity-check every URI from the remote version/update manifest before queuing","Centralize CDN base URL config with startup validation","Log manifest entries with missing URL fields instead of silently queuing them"],"tags":["download","argument-validation","url"],"backgroundTag":"empty-required-field","analyzedSha":"d0c010b05167c58e92350449d04864a91ca13fd2","analyzedAt":"2026-09-15T13:37:15.352Z","contentChangedAt":"2026-09-15T13:37:15.352Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}