CoplayDev/unity-mcp · error · ArgumentException

Input paths cannot be null

Error message

Input paths cannot be null

What it means

Thrown by PreviewGeneratorBase.Validate() (PreviewGeneratorBase.cs:37) when Settings.InputPaths is null or empty. InputPaths is the string[] of asset folders passed to AssetDatabase.FindAssets; null/empty means there is nothing to scan. This base check runs for every generator (both Native and Custom call base.Validate() first), before GenerateImpl() and outside its try/catch, so it propagates as an uncaught ArgumentException.

Source

Thrown at TestProjects/AssetStoreUploads/Packages/com.unity.asset-store-tools/Editor/Previews/Scripts/Generators/PreviewGeneratorBase.cs:37

        }

        public async Task<PreviewGenerationResult> Generate()
        {
            Validate();

            var result = await GenerateImpl();
            if (result.Success)
            {
                CachingService.CacheMetadata(result.GeneratedPreviews);
            }

            return result;
        }

        protected virtual void Validate()
        {
            if (Settings.InputPaths == null || Settings.InputPaths.Length == 0)
                throw new ArgumentException("Input paths cannot be null");

            if (string.IsNullOrEmpty(Settings.OutputPath))
                throw new ArgumentException("Output path cannot be null");
        }

        protected abstract Task<PreviewGenerationResult> GenerateImpl();
    }
}

View on GitHub (pinned to c21bf496bc)

Solutions

  1. Set Settings.InputPaths to a non-empty string[] of asset paths before Generate().
  2. Guard the UI: disable Generate until at least one input path is chosen.
  3. Verify InputPaths is populated right after constructing the settings object.

Example fix

// before
var settings = new CustomPreviewGenerationSettings { OutputPath = outPath, Width = 256, Height = 128, Depth = 100, NativeWidth = 1024, NativeHeight = 1024 };
await new CustomPreviewGenerator(settings).Generate(); // InputPaths null -> throws

// after
var settings = new CustomPreviewGenerationSettings { InputPaths = new[] { "Assets/MyPack" }, OutputPath = outPath, Width = 256, Height = 128, Depth = 100, NativeWidth = 1024, NativeHeight = 1024 };
await new CustomPreviewGenerator(settings).Generate();
Defensive patterns

Strategy: validation

Validate before calling

if (settings.InputPaths == null || settings.InputPaths.Length == 0)
    throw new InvalidOperationException("PreviewGenerationSettings.InputPaths must be a non-empty array before generating.");

Type guard

static bool HasInputPaths(PreviewGenerationSettings s) => s != null && s.InputPaths != null && s.InputPaths.Length > 0;

Try / catch

try { await generator.Generate(); }
catch (ArgumentException ex) when (ex.Message.Contains("Input paths")) { /* report missing input paths */ }

Prevention

When it happens

Trigger: Calling Generate() on any generator whose InputPaths was never set (null) or set to an empty array. Happens when settings are constructed without InputPaths, or when a path picker returns an empty selection.

Common situations: Settings initializer that sets OutputPath but not InputPaths; UI flow that lets the user click Generate with no input paths selected; deserialization that produced an empty array.

Related errors


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