{"record":{"id":"cc6a3cf987a228a3","repo":"CoplayDev/unity-mcp","slug":"export-paths-array-cannot-be-empty","errorCode":null,"errorMessage":"Export paths array cannot be empty","messagePattern":"Export paths array cannot be empty","errorType":"validation","errorClass":"ArgumentException","httpStatus":null,"severity":"error","filePath":"TestProjects/AssetStoreUploads/Packages/com.unity.asset-store-tools/Editor/Exporter/LegacyPackageExporter.cs","lineNumber":28,"sourceCode":"{\r\n    internal class LegacyPackageExporter : PackageExporterBase\r\n    {\r\n        private const string ExportMethodWithoutDependencies = \"UnityEditor.PackageUtility.ExportPackage\";\r\n        private const string ExportMethodWithDependencies = \"UnityEditor.PackageUtility.ExportPackageAndPackageManagerManifest\";\r\n\r\n        private LegacyExporterSettings _legacyExportSettings;\r\n\r\n        public LegacyPackageExporter(LegacyExporterSettings settings) : base(settings)\r\n        {\r\n            _legacyExportSettings = settings;\r\n        }\r\n\r\n        protected override void ValidateSettings()\r\n        {\r\n            base.ValidateSettings();\r\n\r\n            if (_legacyExportSettings.ExportPaths == null || _legacyExportSettings.ExportPaths.Length == 0)\r\n                throw new ArgumentException(\"Export paths array cannot be empty\");\r\n        }\r\n\r\n        protected override async Task<PackageExporterResult> ExportImpl()\r\n        {\r\n            return await this.Export();\r\n        }\r\n\r\n        private async new Task<PackageExporterResult> Export()\r\n        {\r\n            ASDebug.Log(\"Using native package exporter\");\r\n\r\n            try\r\n            {\r\n                var guids = GetGuids(_legacyExportSettings.ExportPaths, out bool onlyFolders);\r\n\r\n                if (guids.Length == 0 || onlyFolders)\r\n                    throw new ArgumentException(\"Package Exporting failed: provided export paths are empty or only contain empty folders\");\r\n\r","sourceCodeStart":10,"sourceCodeEnd":46,"githubUrl":"https://github.com/CoplayDev/unity-mcp/blob/c21bf496bca87d54e75bad048563c3adb1782081/TestProjects/AssetStoreUploads/Packages/com.unity.asset-store-tools/Editor/Exporter/LegacyPackageExporter.cs#L10-L46","documentation":"Thrown by LegacyPackageExporter.ValidateSettings when the ExportPaths array is null or has zero elements. This is a pre-flight validation gate — the exporter refuses to start if no asset paths were supplied. It runs before any GUID collection or reflection-based export call.","triggerScenarios":"Constructing a LegacyPackageExporter with a LegacyExporterSettings whose ExportPaths is null or an empty array, then invoking the export pipeline (which calls ValidateSettings).","commonSituations":"UI binding didn't populate the export paths list; programmatic caller passed an empty array by mistake; settings object was deserialized from JSON/config with a missing or null ExportPaths field.","solutions":["Ensure LegacyExporterSettings.ExportPaths is populated with at least one valid asset folder path before constructing the exporter.","Validate the array at the call site before passing it to the settings constructor.","If loading settings from a serialized source, check for null/empty after deserialization and log a clear upstream error."],"exampleFix":"// before\nvar settings = new LegacyExporterSettings { ExportPaths = paths };\nvar exporter = new LegacyPackageExporter(settings);\nawait exporter.Export();\n\n// after\nif (paths == null || paths.Length == 0)\n    throw new InvalidOperationException(\"Cannot export: no paths provided.\");\nvar settings = new LegacyExporterSettings { ExportPaths = paths };\nvar exporter = new LegacyPackageExporter(settings);\nawait exporter.Export();","handlingStrategy":"validation","validationCode":"if (settings.ExportPaths == null || settings.ExportPaths.Length == 0)\n{\n    Debug.LogError(\"ExportPaths must contain at least one path.\");\n    return; // or throw a descriptive error before constructing the exporter\n}","typeGuard":"static bool HasValidExportPaths(LegacyExporterSettings settings)\n    => settings?.ExportPaths != null && settings.ExportPaths.Length > 0;","tryCatchPattern":"try\n{\n    var exporter = new LegacyPackageExporter(settings);\n    await exporter.Export();\n}\ncatch (ArgumentException ex) when (ex.Message.Contains(\"Export paths array cannot be empty\"))\n{\n    Debug.LogError(\"No export paths provided. Select at least one folder in the Asset Store Tools UI.\");\n}","preventionTips":["Always populate ExportPaths from the UI selection before constructing the exporter.","Validate settings in a separate pre-flight check before starting the async export task.","Use a builder/factory that enforces non-empty paths at construction time."],"tags":["unity","asset-store-tools","validation","packaging","argument-validation"],"backgroundTag":null,"analyzedSha":"c21bf496bca87d54e75bad048563c3adb1782081","analyzedAt":"2026-08-13T17:36:56.095Z","schemaVersion":2},"datasetVersion":"2026-08-13T19:17:28.613Z"}