{"record":{"id":"3fcf5101f9325d98","repo":"CoplayDev/unity-mcp","slug":"source-path-cannot-be-empty","errorCode":null,"errorMessage":"Source path cannot be empty.","messagePattern":"Source path cannot be empty\\.","errorType":"validation","errorClass":"ArgumentException","httpStatus":null,"severity":"error","filePath":"MCPForUnity/Editor/Services/PackageDeploymentService.cs","lineNumber":221,"sourceCode":"            string stamp = DateTime.Now.ToString(\"yyyyMMdd_HHmmss\");\n            string backupPath = Path.Combine(backupRoot, $\"backup_{stamp}\");\n\n            if (Directory.Exists(backupPath))\n            {\n                FileUtil.DeleteFileOrDirectory(backupPath);\n            }\n\n            FileUtil.CopyFileOrDirectory(targetPath, backupPath);\n            return backupPath;\n        }\n\n        private static string ValidateSource(string sourcePath, bool throwOnError = true)\n        {\n            if (string.IsNullOrEmpty(sourcePath))\n            {\n                if (throwOnError)\n                {\n                    throw new ArgumentException(\"Source path cannot be empty.\");\n                }\n\n                return \"Source path is empty.\";\n            }\n\n            if (!Directory.Exists(sourcePath))\n            {\n                if (throwOnError)\n                {\n                    throw new ArgumentException(\"Selected folder does not exist.\");\n                }\n\n                return \"Selected folder does not exist.\";\n            }\n\n            bool hasEditor = Directory.Exists(Path.Combine(sourcePath, \"Editor\"));\n            bool hasRuntime = Directory.Exists(Path.Combine(sourcePath, \"Runtime\"));\n","sourceCodeStart":203,"sourceCodeEnd":239,"githubUrl":"https://github.com/CoplayDev/unity-mcp/blob/c21bf496bca87d54e75bad048563c3adb1782081/MCPForUnity/Editor/Services/PackageDeploymentService.cs#L203-L239","documentation":"Thrown by PackageDeploymentService.ValidateSource (throwOnError=true) when sourcePath is null or empty. ValidateSource is the shared pre-check for package deployment; in throwOnError mode each failure throws ArgumentException. An empty source means no folder was supplied to the deploy flow.","triggerScenarios":"DeployPackage/ValidateSource called with null or empty string; the UI folder-selection field was left blank or returned null.","commonSituations":"Programmatic call with a null variable; UI picker cancelled and returned empty; a pipeline step forgot to set the path.","solutions":["Supply the package source folder path (the folder containing Editor/ and Runtime/).","If calling programmatically, null-check sourcePath before invoking ValidateSource.","In the UI, ensure the folder picker actually returned a selection."],"exampleFix":"// before\nValidateSource(sourcePath, throwOnError: true); // throws if sourcePath == null\n\n// after\nif (string.IsNullOrEmpty(sourcePath)) return Error(\"Pick a package source folder.\");\nValidateSource(sourcePath, throwOnError: true);","handlingStrategy":"validation","validationCode":"if (string.IsNullOrEmpty(sourcePath))\n    return ErrorResponse(\"Pick a package source folder before deploying.\");\nValidateSource(sourcePath, throwOnError: true);","typeGuard":"static bool IsValidSourcePath(string p) => !string.IsNullOrEmpty(p);","tryCatchPattern":"try { ValidateSource(sourcePath, throwOnError: true); }\ncatch (ArgumentException ex) when (ex.Message.Contains(\"empty\"))\n{ /* prompt the user to pick a folder */ }","preventionTips":["Null/empty-check sourcePath at the UI boundary before calling ValidateSource.","Use ValidateSource(throwOnError:false) to collect errors as strings without throwing."],"tags":["package-deployment","validation","path"],"backgroundTag":null,"analyzedSha":"c21bf496bca87d54e75bad048563c3adb1782081","analyzedAt":"2026-08-13T17:36:56.095Z","schemaVersion":2},"datasetVersion":"2026-08-13T19:17:28.613Z"}