CoplayDev/unity-mcp · error · ArgumentException

Export paths array cannot be empty

Error message

Export paths array cannot be empty

What it means

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.

Source

Thrown at TestProjects/AssetStoreUploads/Packages/com.unity.asset-store-tools/Editor/Exporter/LegacyPackageExporter.cs:28

{
    internal class LegacyPackageExporter : PackageExporterBase
    {
        private const string ExportMethodWithoutDependencies = "UnityEditor.PackageUtility.ExportPackage";
        private const string ExportMethodWithDependencies = "UnityEditor.PackageUtility.ExportPackageAndPackageManagerManifest";

        private LegacyExporterSettings _legacyExportSettings;

        public LegacyPackageExporter(LegacyExporterSettings settings) : base(settings)
        {
            _legacyExportSettings = settings;
        }

        protected override void ValidateSettings()
        {
            base.ValidateSettings();

            if (_legacyExportSettings.ExportPaths == null || _legacyExportSettings.ExportPaths.Length == 0)
                throw new ArgumentException("Export paths array cannot be empty");
        }

        protected override async Task<PackageExporterResult> ExportImpl()
        {
            return await this.Export();
        }

        private async new Task<PackageExporterResult> Export()
        {
            ASDebug.Log("Using native package exporter");

            try
            {
                var guids = GetGuids(_legacyExportSettings.ExportPaths, out bool onlyFolders);

                if (guids.Length == 0 || onlyFolders)
                    throw new ArgumentException("Package Exporting failed: provided export paths are empty or only contain empty folders");

View on GitHub (pinned to c21bf496bc)

Solutions

  1. Ensure LegacyExporterSettings.ExportPaths is populated with at least one valid asset folder path before constructing the exporter.
  2. Validate the array at the call site before passing it to the settings constructor.
  3. If loading settings from a serialized source, check for null/empty after deserialization and log a clear upstream error.

Example fix

// before
var settings = new LegacyExporterSettings { ExportPaths = paths };
var exporter = new LegacyPackageExporter(settings);
await exporter.Export();

// after
if (paths == null || paths.Length == 0)
    throw new InvalidOperationException("Cannot export: no paths provided.");
var settings = new LegacyExporterSettings { ExportPaths = paths };
var exporter = new LegacyPackageExporter(settings);
await exporter.Export();
Defensive patterns

Strategy: validation

Validate before calling

if (settings.ExportPaths == null || settings.ExportPaths.Length == 0)
{
    Debug.LogError("ExportPaths must contain at least one path.");
    return; // or throw a descriptive error before constructing the exporter
}

Type guard

static bool HasValidExportPaths(LegacyExporterSettings settings)
    => settings?.ExportPaths != null && settings.ExportPaths.Length > 0;

Try / catch

try
{
    var exporter = new LegacyPackageExporter(settings);
    await exporter.Export();
}
catch (ArgumentException ex) when (ex.Message.Contains("Export paths array cannot be empty"))
{
    Debug.LogError("No export paths provided. Select at least one folder in the Asset Store Tools UI.");
}

Prevention

When it happens

Trigger: Constructing a LegacyPackageExporter with a LegacyExporterSettings whose ExportPaths is null or an empty array, then invoking the export pipeline (which calls ValidateSettings).

Common situations: 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.

Related errors


AI-assisted analysis of CoplayDev/unity-mcp@c21bf496bc (2026-08-13). Data as JSON: /api/errors/cc6a3cf987a228a3. Report an issue: GitHub.