EllanJiang/GameFramework · error · GameFrameworkException
Download uri is invalid.
Error message
Download uri is invalid.
What it means
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.
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
Example fix
// before
string uri = versionInfo.Url; // may be null/empty
DownloadManager.AddDownload(downloadPath, uri, tag, priority, userData);
// after
if (string.IsNullOrEmpty(versionInfo.Url)) { Log.Warning("Missing URL for {0}", versionInfo.Name); return; }
DownloadManager.AddDownload(downloadPath, versionInfo.Url, tag, priority, userData); Defensive patterns
Strategy: validation
Validate before calling
if (string.IsNullOrEmpty(downloadUri)) throw new ArgumentException("downloadUri must be a non-empty URL", nameof(downloadUri));
if (!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"); Type guard
static bool IsValidDownloadUri(string uri) => !string.IsNullOrEmpty(uri) && Uri.TryCreate(uri, UriKind.Absolute, out var u) && (u.Scheme == Uri.UriSchemeHttp || u.Scheme == Uri.UriSchemeHttps);
Try / catch
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); } Prevention
- 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
When it happens
Trigger: Calling AddDownload with downloadUri = null or "", or with a URI read from an update/version manifest entry that was missing or blank.
Common situations: 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.
Understand the failure class
Background: "must not be empty", "cannot be empty" — required-field validation errors across open-source libraries — this error's family across 41 libraries.
Related errors
- Delta length is invalid.
- Download path is invalid.
- Length is invalid.
- Offset is invalid.
- Record interval is invalid.
AI-assisted analysis of EllanJiang/GameFramework@d0c010b051 (2026-09-15).
Data as JSON: /api/errors/500b1f3c3421c662.
Report an issue: GitHub.
Appendix: source
Thrown at GameFramework/Download/DownloadManager.cs:403
/// <summary>
/// 增加下载任务。
/// </summary>
/// <param name="downloadPath">下载后存放路径。</param>
/// <param name="downloadUri">原始下载地址。</param>
/// <param name="tag">下载任务的标签。</param>
/// <param name="priority">下载任务的优先级。</param>
/// <param name="userData">用户自定义数据。</param>
/// <returns>新增下载任务的序列编号。</returns>
public int AddDownload(string downloadPath, string downloadUri, string tag, int priority, object userData)
{
if (string.IsNullOrEmpty(downloadPath))
{
throw new GameFrameworkException("Download path is invalid.");
}
if (string.IsNullOrEmpty(downloadUri))
{
throw new GameFrameworkException("Download uri is invalid.");
}
if (TotalAgentCount <= 0)
{
throw new GameFrameworkException("You must add download agent first.");
}
DownloadTask downloadTask = DownloadTask.Create(downloadPath, downloadUri, tag, priority, m_FlushSize, m_Timeout, userData);
m_TaskPool.AddTask(downloadTask);
return downloadTask.SerialId;
}
/// <summary>
/// 根据下载任务的序列编号移除下载任务。
/// </summary>
/// <param name="serialId">要移除下载任务的序列编号。</param>
/// <returns>是否移除下载任务成功。</returns>
public bool RemoveDownload(int serialId)View on GitHub (pinned to d0c010b051)