{"record":{"id":"7ab8f9135e2c4546","repo":"stride3d/stride","slug":"the-asset-doesn-t-exist-in-the-dependency-manager-anymore","errorCode":null,"errorMessage":"The asset doesn't exist in the dependency manager anymore","messagePattern":"The asset doesn't exist in the dependency manager anymore","errorType":"exception","errorClass":"InvalidOperationException","httpStatus":null,"severity":"error","filePath":"sources/assets/Stride.Core.Assets/PackageSession.Extensions.cs","lineNumber":41,"sourceCode":"        _ = new PackageSession(assetPackageCloned);\n\n        AddAssetToCompilePackage(session, originalAssetItem, assetPackageCloned);\n\n        return assetPackageCloned;\n    }\n\n    public static void AddAssetToCompilePackage(this PackageSession session, AssetItem originalAssetItem, Package assetPackageCloned)\n    {\n        ArgumentNullException.ThrowIfNull(originalAssetItem);\n\n        // Find the asset from the session\n        var assetItem = originalAssetItem.Package?.FindAsset(originalAssetItem.Id)\n            ?? throw new ArgumentException(\"Cannot find the specified AssetItem instance in the session\");\n\n        // Calculate dependencies\n        // Search only for references\n        var dependencies = session.DependencyManager.ComputeDependencies(assetItem.Id, AssetDependencySearchOptions.Out | AssetDependencySearchOptions.Recursive, ContentLinkType.Reference)\n            ?? throw new InvalidOperationException(\"The asset doesn't exist in the dependency manager anymore\");\n        var assetItemRootCloned = dependencies.Item.Clone();\n\n        // Store the fullpath to the sourcefolder, this avoid us to clone hierarchy of packages\n        assetItemRootCloned.SourceFolder = assetItem.FullPath.GetParent();\n\n        if (assetPackageCloned.Assets.Find(assetItemRootCloned.Id) == null)\n            assetPackageCloned.Assets.Add(assetItemRootCloned);\n\n        // For each asset item dependency, clone it in the new package\n        foreach (var assetLink in dependencies.LinksOut)\n        {\n            // Only add assets not already added (in case of circular dependencies)\n            if (assetPackageCloned.Assets.Find(assetLink.Item.Id) == null)\n            {\n                // create a copy of the asset item and add it to the appropriate compile package\n                var itemCloned = assetLink.Item.Clone();\n\n                // Store the fullpath to the sourcefolder, this avoid us to clone hierarchy of packages","sourceCodeStart":23,"sourceCodeEnd":59,"githubUrl":"https://github.com/stride3d/stride/blob/96fad776d210c221682aac1ccdf4c79dc046fc38/sources/assets/Stride.Core.Assets/PackageSession.Extensions.cs#L23-L59","documentation":"After locating the asset item, AddAssetToComputePackage computes outgoing recursive dependencies via session.DependencyManager.ComputeDependencies. A null result means the dependency manager no longer tracks this asset's id, so compilation data cannot be built; an InvalidOperationException is thrown.","triggerScenarios":"Calling AddAssetToCompilePackage when the asset id is absent from session.DependencyManager — e.g. the dependency manager was rebuilt/cleared, the asset was removed, or the session wasn't fully loaded.","commonSituations":"Calling during a partially loaded session, after session.Clear(), or after the asset's package was unloaded so dependency graph nodes were dropped.","solutions":["Ensure the session is fully loaded before building compile packages","Rebuild/refresh the dependency manager (reload session) and retry","Verify the asset still exists and its package is loaded"],"exampleFix":"// before\nsession.AddAssetToCompilePackage(item, cloned); // may throw after Clear()\n// after\nif (session.DependencyManager.FindDependencies(item.Id) != null)\n    session.AddAssetToCompilePackage(item, cloned);","handlingStrategy":"validation","validationCode":"var deps = session.DependencyManager.ComputeDependencies(item.Id, AssetDependencySearchOptions.Out);\nif (deps == null) throw new InvalidOperationException(\"Dependency manager has no node for this asset; reload the session\");","typeGuard":null,"tryCatchPattern":"try { session.AddAssetToCompilePackage(item, cloned); }\ncatch (InvalidOperationException ex) when (ex.Message.Contains(\"dependency manager\"))\n{ logger.Error(ex, \"Dependency graph stale; reload session\"); }","preventionTips":["Only build compile packages on fully loaded sessions","Refresh the dependency graph after structural session changes","Avoid calling right after session.Clear()"],"tags":["assets","dependency-graph","state"],"backgroundTag":"entity-not-found","analyzedSha":"96fad776d210c221682aac1ccdf4c79dc046fc38","analyzedAt":"2026-09-14T02:59:31.279Z","contentChangedAt":"2026-09-14T02:59:31.279Z","schemaVersion":2},"datasetVersion":"2026-09-15T23:17:13.987Z"}