{"record":{"id":"25860948e744b88b","repo":"EllanJiang/GameFramework","slug":"resource-pack-length-is-invalid","errorCode":null,"errorMessage":"Resource pack length is invalid.","messagePattern":"Resource pack length is invalid\\.","errorType":"validation","errorClass":"GameFrameworkException","httpStatus":null,"severity":"error","filePath":"GameFramework/Resource/ResourceManager.ResourceUpdater.cs","lineNumber":355,"sourceCode":"\n                try\n                {\n                    long length = 0L;\n                    ResourcePackVersionList versionList = default(ResourcePackVersionList);\n                    using (FileStream fileStream = new FileStream(resourcePackPath, FileMode.Open, FileAccess.Read))\n                    {\n                        length = fileStream.Length;\n                        versionList = m_ResourceManager.m_ResourcePackVersionListSerializer.Deserialize(fileStream);\n                    }\n\n                    if (!versionList.IsValid)\n                    {\n                        throw new GameFrameworkException(\"Deserialize resource pack version list failure.\");\n                    }\n\n                    if (versionList.Offset + versionList.Length != length)\n                    {\n                        throw new GameFrameworkException(\"Resource pack length is invalid.\");\n                    }\n\n                    m_ApplyingResourcePackPath = resourcePackPath;\n                    m_ApplyingResourcePackStream = new FileStream(resourcePackPath, FileMode.Open, FileAccess.Read);\n                    m_ApplyingResourcePackStream.Position = versionList.Offset;\n                    m_FailureFlag = false;\n\n                    long totalLength = 0L;\n                    ResourcePackVersionList.Resource[] resources = versionList.GetResources();\n                    foreach (ResourcePackVersionList.Resource resource in resources)\n                    {\n                        ResourceName resourceName = new ResourceName(resource.Name, resource.Variant, resource.Extension);\n                        UpdateInfo updateInfo = null;\n                        if (!m_UpdateCandidateInfo.TryGetValue(resourceName, out updateInfo))\n                        {\n                            continue;\n                        }\n","sourceCodeStart":337,"sourceCodeEnd":373,"githubUrl":"https://github.com/EllanJiang/GameFramework/blob/d0c010b05167c58e92350449d04864a91ca13fd2/GameFramework/Resource/ResourceManager.ResourceUpdater.cs#L337-L373","documentation":"ApplyResources throws this when the version list's Offset + Length does not equal the actual pack file length. The resource pack version list records where the embedded data sits in the file; a mismatch means the file is truncated, extended, or from a different build.","triggerScenarios":"Applying a partially downloaded/truncated pack file; appending or modifying pack bytes after generation; pack file and version list built by mismatched pipeline versions.","commonSituations":"Network download interrupted and file saved anyway; file transfer in text mode corrupting bytes; manually merging or editing pack files; server serving an outdated pack.","solutions":["Re-download the resource pack and verify its byte length against the server manifest before applying","Regenerate the resource pack so the version list offsets match the file contents","Ensure binary-safe transfer (no text-mode or encoding transformations) when copying the pack"],"exampleFix":"// before\nresourceManager.ApplyResources(\"pack.dat\"); // file truncated, length mismatch\n// after\nif (new FileInfo(\"pack.dat\").Length == manifest.ExpectedLength) resourceManager.ApplyResources(\"pack.dat\");\nelse RetryDownload(\"pack.dat\", manifest.ExpectedLength);","handlingStrategy":"validation","validationCode":"if (new FileInfo(packPath).Length != manifest.ExpectedLength) { Redownload(packPath); return; }","typeGuard":null,"tryCatchPattern":"try { resourceManager.ApplyResources(packPath); } catch (GameFrameworkException ex) { Log.Error(\"Resource pack length mismatch, redownloading: \" + ex.Message); RedownloadPack(); }","preventionTips":["Verify downloaded file size matches the manifest byte count before applying","Use binary-safe transfer for pack files","Regenerate packs whenever the resource pipeline version changes"],"tags":["csharp","gameframework","file-integrity","resource-pack"],"backgroundTag":"checksum-mismatch","analyzedSha":"d0c010b05167c58e92350449d04864a91ca13fd2","analyzedAt":"2026-09-15T13:37:15.352Z","contentChangedAt":"2026-09-15T13:37:15.352Z","schemaVersion":2},"datasetVersion":"2026-09-16T04:17:20.429Z"}