CoplayDev/unity-mcp · error · ArgumentException
Path does not correspond to a valid package
Error message
Path does not correspond to a valid package
What it means
Thrown by HybridPackageWorkflow.SetPackage when PackageUtility.GetPackageByManifestPath cannot resolve the given packageManifestPath to a Unity package. The asset-store uploader relies on Unity's package resolver to locate a package.json and its PackageInfo; if the manifest path is invalid or not inside a recognized package, the resolver returns false and this ArgumentException is raised before any metadata is set.
Source
Thrown at TestProjects/AssetStoreUploads/Packages/com.unity.asset-store-tools/Editor/Uploader/Scripts/Data/HybridPackageWorkflow.cs:57
{
return _packageInfo;
}
public void SetPackage(PackageInfo packageInfo, bool serialize)
{
if (packageInfo == null)
throw new ArgumentException("Package is null");
_packageInfo = packageInfo;
SetMetadata();
if (serialize)
Serialize();
}
public void SetPackage(string packageManifestPath, bool serialize)
{
if (!PackageUtility.GetPackageByManifestPath(packageManifestPath, out var package))
throw new ArgumentException("Path does not correspond to a valid package");
SetPackage(package, serialize);
}
private void SetMetadata()
{
LocalPackageGuid = AssetDatabase.AssetPathToGUID(AssetDatabase.GetAssetPath(_packageInfo.GetManifestAsset()));
LocalPackagePath = _packageInfo.assetPath;
LocalProjectPath = _packageInfo.name;
}
public List<PackageInfo> GetDependencies()
{
return _dependencies;
}
public void SetDependencies(IEnumerable<string> dependencies, bool serialize)
{
View on GitHub (pinned to c21bf496bc)
Solutions
- Verify the path points to an existing package.json inside Packages/<package-id>/.
- Force Unity to refresh package resolution: trigger an AssetDatabase refresh or reimport before uploading.
- If the package was moved, re-select it through the uploader UI so it stores the resolved manifest path.
- Confirm the manifest path uses forward slashes and correct casing on macOS/Linux editors.
Example fix
// before
workflow.SetPackage("Packages/com.my.pkg", serialize: true);
// after
workflow.SetPackage("Packages/com.my.pkg/package.json", serialize: true); Defensive patterns
Strategy: validation
Validate before calling
if (!PackageUtility.GetPackageByManifestPath(path, out var pkg))
throw new ArgumentException($"Not a valid package manifest: {path}"); Type guard
static bool IsValidManifestPath(string path) =>
!string.IsNullOrEmpty(path)
&& path.EndsWith("package.json")
&& File.Exists(path)
&& PackageUtility.GetPackageByManifestPath(path, out _); Try / catch
try { workflow.SetPackage(path, serialize: true); }
catch (ArgumentException ex) { Debug.LogError(ex.Message); } Prevention
- Always pass the package.json file path, not the folder.
- Re-resolve the package after moving/renaming it.
When it happens
Trigger: Calling AssetStoreUploader with a packageManifestPath that does not point to a valid package.json, points to a file outside the Packages folder, is a removed/embedded-local package not yet imported, or a path with the wrong casing/separators on case-sensitive systems.
Common situations: A package was deleted or renamed between selection and upload; the path passed is the folder rather than the package.json; or a Local/Embedded package is not yet registered by Unity's AssetDatabase. Common after moving a package or switching branches.
Related errors
- Source directory not found: {dir.FullName}
- No validation paths were set
- The following directories do not exist:
- Package was not found
- Could not find external project's validation results
AI-assisted analysis of CoplayDev/unity-mcp@c21bf496bc (2026-08-13).
Data as JSON: /api/errors/6a2432691d42fcd7.
Report an issue: GitHub.