{"record":{"id":"1f7a234f23eff426","repo":"stride3d/stride","slug":"data-chunk-is-missing-or-has-invalid-size","errorCode":null,"errorMessage":"Data chunk is missing or has invalid size.","messagePattern":"Data chunk is missing or has invalid size\\.","errorType":"exception","errorClass":"ContentStreamingException","httpStatus":null,"severity":"error","filePath":"sources/engine/Stride.Graphics/Data/ImageTextureSerializer.cs","lineNumber":105,"sourceCode":"                var buffer = MemoryUtilities.Allocate(size);\n\n                try\n                {\n                    // Load image data to the buffer\n                    var bufferPtr = buffer;\n                    for (int arrayIndex = 0; arrayIndex < imageDescription.ArraySize; arrayIndex++)\n                    {\n                        for (int mipIndex = 0; mipIndex < imageDescription.MipLevels; mipIndex++)\n                        {\n                            var (mipWidth, mipHeight) = Image.GetMipDimensions(format, imageDescription.Width, imageDescription.Height, mipIndex);\n\n                            int rowPitch, slicePitch;\n                            int widthPacked;\n                            int heightPacked;\n                            Image.ComputePitch(format, mipWidth, mipHeight, out rowPitch, out slicePitch, out widthPacked, out heightPacked);\n                            var chunk = storage.GetChunk(mipIndex);\n                            if (chunk == null || chunk.Size != slicePitch * imageDescription.ArraySize)\n                                throw new ContentStreamingException(\"Data chunk is missing or has invalid size.\", storage);\n                            var data = chunk.GetData(fileProvider);\n                            if (!chunk.IsLoaded)\n                                throw new ContentStreamingException(\"Data chunk is not loaded.\", storage);\n\n                            MemoryUtilities.CopyWithAlignmentFallback((void*)bufferPtr, (void*)data, (uint)chunk.Size);\n                            bufferPtr += chunk.Size;\n                        }\n                    }\n\n                    // Initialize image\n                    var image = new Image(imageDescription, buffer, 0, null, true);\n                    obj.InitializeFrom(image);\n                }\n                catch\n                {\n                    // Free memory in case of error\n                    MemoryUtilities.Free(buffer);\n","sourceCodeStart":87,"sourceCodeEnd":123,"githubUrl":"https://github.com/stride3d/stride/blob/96fad776d210c221682aac1ccdf4c79dc046fc38/sources/engine/Stride.Graphics/Data/ImageTextureSerializer.cs#L87-L123","documentation":"During image deserialization, each mip level's raw pixel data is stored as a chunk in the ContentStorage. This error is thrown when the chunk for a mip level is absent (GetChunk returned null) or its Size does not match the expected slicePitch * ArraySize computed via Image.ComputePitch. It indicates the serialized texture asset data is corrupt, truncated, or was produced with a mismatched format/size layout.","triggerScenarios":"Calling DeserializeImage (during texture Serialize/deserialization pipeline) with a storage whose chunk for mipIndex is missing, or a chunk whose byte size differs from slicePitch*ArraySize for the ImageDescription's format and mip dimensions.","commonSituations":"Asset files truncated by bad uploads or interrupted builds; texture assets serialized with an older Stride version or different pixel format than the descriptor expects; hand-edited or corrupted data containers; storage header pointing to the wrong asset.","solutions":["Re-import/rebuild the texture asset so the storage container is regenerated with correct chunk sizes.","Verify the ImageDescription (Format, Width, Height, MipLevels, ArraySize) matches what the asset was serialized with; fix format mismatches.","Check the source asset file is not truncated or corrupted (compare checksums, re-download).","Clear intermediate/object build caches and rebuild the content pipeline output."],"exampleFix":null,"handlingStrategy":"validation","validationCode":"var chunk = storage.GetChunk(mipIndex);\nImage.ComputePitch(format, mipWidth, mipHeight, out _, out int slicePitch, out _, out _);\nbool valid = chunk != null && chunk.Size == slicePitch * imageDescription.ArraySize;","typeGuard":"bool HasValidChunk(ContentStorage storage, int mipIndex, int expectedSize) => storage.GetChunk(mipIndex) is { } c && c.Size == expectedSize;","tryCatchPattern":"try { obj = serializer.Deserialize(context); }\ncatch (ContentStreamingException ex) when (ex.Message.Contains(\"Data chunk\"))\n{\n    logger.LogError(ex, \"Corrupt texture chunk\");\n    // fallback: reload or rebuild asset\n}","preventionTips":["Rebuild assets after Stride version upgrades to keep headers and chunk sizes in sync","Checksum-verify assets after build/deploy to catch truncation","Never hand-edit serialized texture containers","Validate ImageDescription (Format, MipLevels, ArraySize) matches the producing build"],"tags":["content-pipeline","textures","serialization","stride"],"backgroundTag":"schema-validation-failed","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"}