{"record":{"id":"a8154c4f104496f8","repo":"stride3d/stride","slug":"can-t-pack-files","errorCode":null,"errorMessage":"Can't pack files.","messagePattern":"Can't pack files\\.","errorType":"exception","errorClass":"InvalidOperationException","httpStatus":null,"severity":"error","filePath":"sources/core/Stride.Core.Serialization/Storage/ObjectDatabase.cs","lineNumber":144,"sourceCode":"    }\n\n    public void Dispose()\n    {\n        backendRead1.Dispose();\n        if (backendRead2 != null && !ReferenceEquals(backendRead2, backendRead1))\n        {\n            backendRead2.Dispose();\n        }\n        if (backendWrite != null && !ReferenceEquals(backendRead2, backendWrite) && !ReferenceEquals(backendRead2, backendRead1))\n        {\n            backendWrite.Dispose();\n        }\n    }\n\n    public string? CreateBundle(ObjectId[] objectIds, string bundleName, BundleOdbBackend bundleBackend, ISet<ObjectId> disableCompressionIds, Dictionary<string, ObjectId> indexMap, IList<string> dependencies, bool useIncrementalBundle)\n    {\n        if (bundleBackend == null)\n            throw new InvalidOperationException(\"Can't pack files.\");\n\n        if (objectIds.Length == 0)\n            return null;\n\n        var packUrl = bundleBackend.BundleDirectory + bundleName + BundleOdbBackend.BundleExtension; // we don't want the pack to be compressed in the APK on android\n\n        // Create pack\n        BundleOdbBackend.CreateBundle(packUrl, backendRead1, objectIds, disableCompressionIds, indexMap, dependencies, useIncrementalBundle);\n        return packUrl;\n    }\n\n    public bool TryGetObjectLocation(ObjectId objectId, [NotNullWhen(true)] out string? filePath, out long start, out long end)\n    {\n        if (BundleBackend != null && BundleBackend.TryGetObjectLocation(objectId, out filePath, out start, out end))\n            return true;\n\n        foreach (var backend in new[] { backendRead1, backendRead2 })\n        {","sourceCodeStart":126,"sourceCodeEnd":162,"githubUrl":"https://github.com/stride3d/stride/blob/96fad776d210c221682aac1ccdf4c79dc046fc38/sources/core/Stride.Core.Serialization/Storage/ObjectDatabase.cs#L126-L162","documentation":"ObjectDatabase.CreateBundle throws this when the bundle backend (IOdbBackend for writing bundles) is null. Bundles are prepacked asset files; without a valid BundleOdbBackend there is nowhere to write the pack, so the library refuses rather than fail later. Callers typically get here via topBundleUrl when preparing asset bundles.","triggerScenarios":"Calling ObjectDatabase.CreateBundle (directly or via topBundleUrl) when the object database was opened without a bundle-capable write backend (bundleBackend parameter null).","commonSituations":"Opening a read-only object database (e.g. mounted from an APK or read-only asset store) and then attempting to generate bundles; forgetting to configure BundleOdbBackend in the game asset compiler/packager; passing a null backend programmatically.","solutions":["Configure the ObjectDatabase with a valid BundleOdbBackend (BundleDirectory set) before calling CreateBundle.","Run bundle creation from the game studio/asset compiler where a writable bundle backend is attached, not at runtime from a read-only database.","Guard the call site: skip or log when bundleBackend is null instead of invoking CreateBundle."],"exampleFix":"// before\nvar url = database.CreateBundle(objectIds, bundleName, null, disableCompressionIds, indexMap, dependencies, false);\n// after\nvar backend = new BundleOdbBackend(database, bundleDirectory, VirtualFileSystem.GetFileProvider(bundleDirectory));\nif (backend == null) throw new InvalidOperationException(\"Bundle backend not configured\");\nvar url = database.CreateBundle(objectIds, bundleName, backend, disableCompressionIds, indexMap, dependencies, false);","handlingStrategy":"validation","validationCode":"if (bundleBackend == null)\n    throw new InvalidOperationException(\"CreateBundle requires a configured BundleOdbBackend; initialize the object database with a writable bundle backend first.\");","typeGuard":null,"tryCatchPattern":"try { url = database.CreateBundle(ids, name, backend, ...); }\ncatch (InvalidOperationException ex) when (ex.Message == \"Can't pack files.\") {\n    logger.Error(\"Bundle backend not configured; cannot pack assets.\");\n}","preventionTips":["Always initialize ObjectDatabase with a BundleOdbBackend before any pack operation","Only run bundle creation in tooling contexts with write access","Add an assertion/precondition at API boundaries that accept backends"],"tags":["serialization","object-database","bundles","invalid-state"],"backgroundTag":"null-argument","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"}