{"record":{"id":"47c7eace078388d5","repo":"CoplayDev/unity-mcp","slug":"selected-folder-does-not-exist","errorCode":null,"errorMessage":"Selected folder does not exist.","messagePattern":"Selected folder does not exist\\.","errorType":"exception","errorClass":"ArgumentException","httpStatus":null,"severity":"error","filePath":"MCPForUnity/Editor/Services/PackageDeploymentService.cs","lineNumber":231,"sourceCode":"        }\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\n            if (!hasEditor || !hasRuntime)\n            {\n                string message = \"Folder must contain Editor and Runtime subfolders.\";\n                if (throwOnError)\n                {\n                    throw new ArgumentException(message);\n                }\n\n                return message;\n            }","sourceCodeStart":213,"sourceCodeEnd":249,"githubUrl":"https://github.com/CoplayDev/unity-mcp/blob/c21bf496bca87d54e75bad048563c3adb1782081/MCPForUnity/Editor/Services/PackageDeploymentService.cs#L213-L249","documentation":"Thrown by ValidateSource when sourcePath is non-empty but Directory.Exists returns false — the folder is not present on disk. This catches deleted/moved source folders and paths that never existed before deployment attempts to copy from them.","triggerScenarios":"sourcePath points to a folder that was deleted, moved, or never created; a relative path resolved against an unexpected working directory; a typo in the path.","commonSituations":"Folder moved/deleted after being selected in the UI; relative path assuming the wrong cwd; path copied with a typo; external drive unmounted.","solutions":["Verify the folder exists on disk (Directory.Exists) before deploying.","Re-select the folder in the UI picker, or pass a verified absolute path.","If using a relative path, resolve it to absolute (Path.GetFullPath) first to confirm location."],"exampleFix":"// before\nValidateSource(sourcePath, throwOnError: true); // throws if folder gone\n\n// after\nif (!Directory.Exists(sourcePath)) return Error($\"Folder not found: {sourcePath}\");\nValidateSource(sourcePath, throwOnError: true);","handlingStrategy":"validation","validationCode":"if (!Directory.Exists(sourcePath))\n    return ErrorResponse($\"Source folder not found: {sourcePath}\");\nValidateSource(sourcePath, throwOnError: true);","typeGuard":"static bool SourceFolderExists(string p) => !string.IsNullOrEmpty(p) && Directory.Exists(p);","tryCatchPattern":"try { ValidateSource(sourcePath, throwOnError: true); }\ncatch (ArgumentException ex) when (ex.Message.Contains(\"does not exist\"))\n{ /* re-pick the folder; it was moved/deleted */ }","preventionTips":["Check Directory.Exists right before deploying; re-select if stale.","Prefer absolute paths to avoid cwd-relative surprises.","Re-validate after long gaps between selection and deployment."],"tags":["package-deployment","validation","path","filesystem"],"backgroundTag":null,"analyzedSha":"c21bf496bca87d54e75bad048563c3adb1782081","analyzedAt":"2026-08-13T17:36:56.095Z","schemaVersion":2},"datasetVersion":"2026-08-13T19:17:28.613Z"}