{"record":{"id":"b48d9560589a2282","repo":"EllanJiang/GameFramework","slug":"download-path-is-invalid","errorCode":null,"errorMessage":"Download path is invalid.","messagePattern":"Download path is invalid\\.","errorType":"exception","errorClass":"GameFrameworkException","httpStatus":null,"severity":"error","filePath":"GameFramework/Download/DownloadManager.cs","lineNumber":398,"sourceCode":"        public int AddDownload(string downloadPath, string downloadUri, int priority, object userData)\n        {\n            return AddDownload(downloadPath, downloadUri, null, priority, userData);\n        }\n\n        /// <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>","sourceCodeStart":380,"sourceCodeEnd":416,"githubUrl":"https://github.com/EllanJiang/GameFramework/blob/d0c010b05167c58e92350449d04864a91ca13fd2/GameFramework/Download/DownloadManager.cs#L380-L416","documentation":"GameFramework's DownloadManager.AddDownload throws this when the downloadPath parameter is null or an empty string. The download path identifies where the downloaded file will be saved locally, so the manager refuses to create a task without it. It is a fail-fast argument validation thrown as a GameFrameworkException before any agent or task pool work begins.","triggerScenarios":"Calling AddDownload (any overload) with downloadPath = null, downloadPath = \"\", or a path built from an expression that evaluated to empty (e.g. string.Format with missing data, a config field that was never set).","commonSituations":"Download directory config value left blank in the game's settings table; a path constructed by joining a base folder that is empty; renaming/refactoring code so the path variable is no longer populated before the call.","solutions":["Ensure a non-empty local file path is passed as downloadPath before calling AddDownload","Validate with string.IsNullOrEmpty(downloadPath) at the call site and log/abort early","Check the configuration or data source that supplies the path (config table, remote update info) is populated"],"exampleFix":"// before\nDownloadManager.AddDownload(null, downloadUri, tag, priority, userData);\n// after\nstring downloadPath = Path.Combine(Application.persistentDataPath, \"update.dat\");\nint serialId = DownloadManager.AddDownload(downloadPath, downloadUri, tag, priority, userData);","handlingStrategy":"validation","validationCode":"if (string.IsNullOrEmpty(downloadPath)) throw new ArgumentException(\"downloadPath must be a non-empty local path\", nameof(downloadPath));","typeGuard":"static bool IsValidDownloadPath(string path) => !string.IsNullOrEmpty(path);","tryCatchPattern":"try { int id = downloadManager.AddDownload(path, uri, tag, priority, userData); } catch (GameFrameworkException ex) when (ex.Message == \"Download path is invalid.\") { Log.Error(\"Invalid download path: '{0}'\", path); }","preventionTips":["Resolve download paths through a single helper that guarantees a rooted, non-empty path","Validate all path config fields at startup, fail early","Unit-test download task creation with boundary inputs"],"tags":["download","argument-validation","gameframework"],"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-15T23:17:13.987Z"}