{"record":{"id":"bdf54d92753b3b8f","repo":"stride3d/stride","slug":"assetitem-must-belong-to-an-existing-package","errorCode":null,"errorMessage":"AssetItem must belong to an existing package","messagePattern":"AssetItem must belong to an existing package","errorType":"exception","errorClass":"InvalidOperationException","httpStatus":null,"severity":"error","filePath":"sources/assets/Stride.Core.Assets/Analysis/AssetAnalysis.cs","lineNumber":55,"sourceCode":"    }\n\n    public static LoggerResult FixAssetReferences(IEnumerable<AssetItem> items)\n    {\n        var parameters = new AssetAnalysisParameters() { IsProcessingAssetReferences = true, IsLoggingAssetNotFoundAsError =  true};\n        var result = new LoggerResult();\n        Run(items, result, parameters);\n        return result;\n    }\n\n    public static void Run(AssetItem assetItem, ILogger log, AssetAnalysisParameters parameters)\n    {\n        ArgumentNullException.ThrowIfNull(assetItem);\n        ArgumentNullException.ThrowIfNull(log);\n        ArgumentNullException.ThrowIfNull(parameters);\n\n        if (assetItem.Package is null)\n        {\n            throw new InvalidOperationException(\"AssetItem must belong to an existing package\");\n        }\n\n        var package = assetItem.Package;\n\n        // Check that there is no duplicate in assets\n        if (package.Session is not null)\n        {\n            var packages = package.FindDependencies();\n\n            foreach (var otherPackage in packages)\n            {\n                var existingAsset = otherPackage.Assets.Find(assetItem.Id);\n\n                if (existingAsset is not null)\n                {\n                    log.Error($\"Assets [{existingAsset.FullPath}] with id [{existingAsset.Id}] from Package [{package.FullPath}] is already loaded from package [{existingAsset.Package?.FullPath}]\");\n                }\n                else","sourceCodeStart":37,"sourceCodeEnd":73,"githubUrl":"https://github.com/stride3d/stride/blob/96fad776d210c221682aac1ccdf4c79dc046fc38/sources/assets/Stride.Core.Assets/Analysis/AssetAnalysis.cs#L37-L73","documentation":"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.","triggerScenarios":"Thrown at sources/assets/Stride.Core.Assets/Analysis/AssetAnalysis.cs:55 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","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"],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"96fad776d210c221682aac1ccdf4c79dc046fc38","analyzedAt":"2026-09-14T02:59:31.279Z","contentChangedAt":"2026-09-14T02:59:31.279Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}