stride3d/stride · error · InvalidOperationException
AssetItem must belong to an existing package
Error message
AssetItem must belong to an existing package
What it means
Validation inside AssetAnalysis.Run: the analysis requires every processed AssetItem to be attached to a Package (assetItem.Package != null). A standalone AssetItem that was never added to a package reaches the analysis, which cannot resolve references without a package context.
Solutions
- Add the asset to a package via Package.Assets.Add / PackageSession before running analysis
- Construct the AssetItem with the owning package argument
- Filter out package-less items before passing the collection to Run
Defensive patterns
Strategy: validation
When it happens
Trigger: Thrown at sources/assets/Stride.Core.Assets/Analysis/AssetAnalysis.cs:55 when the library encounters an invalid state.
Common situations: See trigger scenarios.
AI-assisted analysis of stride3d/stride@96fad776d2 (2026-09-14).
Data as JSON: /api/errors/bdf54d92753b3b8f.
Report an issue: GitHub.
Appendix: source
Thrown at sources/assets/Stride.Core.Assets/Analysis/AssetAnalysis.cs:55
}
public static LoggerResult FixAssetReferences(IEnumerable<AssetItem> items)
{
var parameters = new AssetAnalysisParameters() { IsProcessingAssetReferences = true, IsLoggingAssetNotFoundAsError = true};
var result = new LoggerResult();
Run(items, result, parameters);
return result;
}
public static void Run(AssetItem assetItem, ILogger log, AssetAnalysisParameters parameters)
{
ArgumentNullException.ThrowIfNull(assetItem);
ArgumentNullException.ThrowIfNull(log);
ArgumentNullException.ThrowIfNull(parameters);
if (assetItem.Package is null)
{
throw new InvalidOperationException("AssetItem must belong to an existing package");
}
var package = assetItem.Package;
// Check that there is no duplicate in assets
if (package.Session is not null)
{
var packages = package.FindDependencies();
foreach (var otherPackage in packages)
{
var existingAsset = otherPackage.Assets.Find(assetItem.Id);
if (existingAsset is not null)
{
log.Error($"Assets [{existingAsset.FullPath}] with id [{existingAsset.Id}] from Package [{package.FullPath}] is already loaded from package [{existingAsset.Package?.FullPath}]");
}
elseView on GitHub (pinned to 96fad776d2)