CoplayDev/unity-mcp · error · ArgumentException

uid required

Error message

uid required

What it means

StartMarketplaceImport requires a non-empty marketplace asset uid (e.g. a Sketchfab model id). It throws ArgumentException ('uid required') immediately if the uid is null or empty, before any provider adapter or network call. The comment notes the adapter itself throws NotSupported if unimplemented downstream.

Source

Thrown at MCPForUnity/Editor/Services/AssetGen/AssetGenJobManager.cs:178

            var runner = new Runner
            {
                Job = job,
                SubmitFn = ct => adapter.SubmitAsync(req, apiKey, transport, ct),
                PollFn = (pid, ct) => adapter.PollAsync(pid, apiKey, transport, ct),
                ImportFn = ImportOverrideForTests ?? AudioImportPipeline.ImportInto,
                Transport = transport,
                OutputFolder = req.OutputFolder,
                Ext = "wav", // default; the poll's ResultExt (wav/mp3) overrides at write time
                Name = NameFrom(req.Name, req.Prompt, job.JobId),
                Subfolder = "Audio",
            };
            Register(job, runner);
            return job;
        }

        public static AssetGenJob StartMarketplaceImport(string uid, float targetSize, string name, string outputFolder)
        {
            if (string.IsNullOrEmpty(uid)) throw new ArgumentException("uid required");
            var adapter = AssetGenProviders.Marketplace("sketchfab"); // throws NotSupported if unimplemented
            var job = NewJob("marketplace", "sketchfab", "import");
            job.TargetSize = targetSize <= 0 ? 1f : targetSize;
            if (!TryResolveKey("sketchfab", job, out string apiKey)) return job;
            var transport = TransportOverrideForTests ?? new UnityWebRequestTransport();
            var runner = new Runner
            {
                Job = job,
                SubmitFn = ct => adapter.ResolveDownloadUrlAsync(uid, apiKey, transport, ct),   // returns the zip/gltf URL as providerJobId
                PollFn = (pid, ct) => Task.FromResult(new ProviderPollResult { State = ProviderPollState.Succeeded, Progress = 1f, DownloadUrl = pid, ResultExt = "zip" }),
                ImportFn = ImportOverrideForTests ?? ModelImportPipeline.ImportInto,
                Transport = transport,
                OutputFolder = outputFolder,
                Ext = "zip",
                Name = NameFrom(name, uid, job.JobId),
                Subfolder = "Sketchfab",
            };
            Register(job, runner);

View on GitHub (pinned to c21bf496bc)

Solutions

  1. Ensure a non-empty marketplace uid is obtained from search results before calling import.
  2. Guard for null/empty uid at the call site and surface a clear error to the user.
  3. If search returned nothing, report 'no results' rather than attempting an import.

Example fix

// before
AssetGenJob.StartMarketplaceImport(uid: selectedUid, ...); // selectedUid may be null

// after
if (string.IsNullOrEmpty(selectedUid))
    return Error("Select a marketplace asset first.");
AssetGenJob.StartMarketplaceImport(uid: selectedUid, ...);
Defensive patterns

Strategy: validation

Validate before calling

if (string.IsNullOrWhiteSpace(uid))
    throw new ArgumentException("A marketplace asset uid is required to start an import.", nameof(uid));
AssetGenJob.StartMarketplaceImport(uid, targetSize, name, outputFolder);

Type guard

static bool IsValidMarketplaceUid(string uid) => !string.IsNullOrWhiteSpace(uid);

Try / catch

try { AssetGenJob.StartMarketplaceImport(uid, ...); }
catch (ArgumentException ex) when (ex.Message.Contains("uid required"))
{
    // Upstream search produced no id; prompt the user to select an asset.
    Report("Select a marketplace asset before importing.");
}

Prevention

When it happens

Trigger: Calling StartMarketplaceImport with "" or null uid; a preceding search step returned no id and that empty value was forwarded into import.

Common situations: An AI/LLM omitting the uid; upstream search returning an empty result set whose code path forwarded an absent id; a UI/API caller forgetting to select an asset.

Related errors


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