{"record":{"id":"dc1b9784eefd57b9","repo":"stride3d/stride","slug":"invalid-bundle-header","errorCode":null,"errorMessage":"Invalid bundle header","messagePattern":"Invalid bundle header","errorType":"exception","errorClass":"InvalidOperationException","httpStatus":null,"severity":"error","filePath":"sources/core/Stride.Core.Serialization/Storage/BundleOdbBackend.cs","lineNumber":392,"sourceCode":"    /// or\n    /// Bundle has not been properly written\n    /// </exception>\n    public static BundleDescription ReadBundleDescription(Stream stream)\n    {\n        var binaryReader = new BinarySerializationReader(stream);\n\n        // Read header\n        var header = binaryReader.Read<Header>();\n\n        var result = new BundleDescription\n        {\n            Header = header\n        };\n\n        // Check magic header\n        if (header.MagicHeader != Header.MagicHeaderValid)\n        {\n            throw new InvalidOperationException(\"Invalid bundle header\");\n        }\n\n        // Ensure size has properly been set\n        if (header.Size != stream.Length)\n        {\n            throw new InvalidOperationException(\"Bundle has not been properly written\");\n        }\n\n        // Read dependencies\n        var dependencies = result.Dependencies;\n        binaryReader.Serialize(ref dependencies, ArchiveMode.Deserialize);\n\n        // Read incremental bundles\n        var incrementalBundles = result.IncrementalBundles;\n        binaryReader.Serialize(ref incrementalBundles, ArchiveMode.Deserialize);\n\n        // Read objects\n        var objects = result.Objects;","sourceCodeStart":374,"sourceCodeEnd":410,"githubUrl":"https://github.com/stride3d/stride/blob/96fad776d210c221682aac1ccdf4c79dc046fc38/sources/core/Stride.Core.Serialization/Storage/BundleOdbBackend.cs#L374-L410","documentation":"ReadBundleDescription validates the bundle's magic header after deserializing it; a mismatch with Header.MagicHeaderValid throws InvalidOperationException. The stream being read is not a valid Stride bundle file (wrong format, corrupted, or truncated at the start).","triggerScenarios":"ReadBundleHeader/CreateBundle reading a file that is not a bundle (e.g. a plain asset or text file renamed to .bundle), a corrupted download, or a byte-order/version mismatch from a different Stride serialization version.","commonSituations":"Manually renamed data files, partial uploads/ftp transfers in ASCII mode, mixing bundle files between incompatible engine versions.","solutions":["Point the loader at a genuine .bundle file produced by Stride's packager, not an arbitrary file.","Re-transfer/re-generate the bundle; verify with checksum comparison against the build output.","Confirm the runtime Stride version can read bundles written by the build tool version."],"exampleFix":"// before\nvar bundle = ReadBundleHeader(\"logo.png\"); // wrong file type\n// after\nvar bundle = ReadBundleHeader(\"bundles/logo.bundle\");","handlingStrategy":"validation","validationCode":"static readonly byte[] MagicHeaderValid = { /* Stride bundle magic */ };\nstatic bool LooksLikeBundle(string path)\n{\n    using var fs = File.OpenRead(path);\n    Span<byte> head = stackalloc byte[MagicHeaderValid.Length];\n    return fs.Read(head) == MagicHeaderValid.Length && head.SequenceEqual(MagicHeaderValid);\n}","typeGuard":null,"tryCatchPattern":"try\n{\n    var bundle = ReadBundleHeader(bundleUrl, out var files);\n}\ncatch (InvalidOperationException ex) when (ex.Message == \"Invalid bundle header\")\n{\n    throw new InvalidDataException($\"{bundleUrl} is not a valid Stride bundle (bad magic header).\", ex);\n}","preventionTips":["Only point the loader at files produced by the Stride packager.","Verify file hashes after download/transfer to catch corruption early.","Keep engine and build-tool versions aligned to avoid format drift."],"tags":["bundles","corruption","file-format"],"backgroundTag":"checksum-mismatch","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"}