stride3d/stride · error · ContentStreamingException
Invalid hash code.
Error message
Invalid hash code.
What it means
ContentStorage.Init reads a .pkt bundle header and reconstructs chunk entries, then validates that the recomputed GetHashCode() matches the header's stored HashCode. A mismatch means the storage index file was corrupted, truncated, or hand-edited — content integrity cannot be trusted.
Solutions
- Rebuild the bundle/storage by re-running the asset compiler/game studio packaging step.
- Restore the corrupted .pkt file from a known-good build artifact.
- Verify file integrity after download/copy (hash the whole file) before loading; if you serialize custom storage, keep header hash computation in sync with ContentStorage.GetHashCode.
Example fix
// no code fix — data problem
// before: load corrupt bundle
var storage = ContentStorage.Load(provider, url);
// after: validate first
if (!FileChecksumMatches(url, expectedHash))
throw new InvalidOperationException("Bundle corrupted; repackage assets");
var storage = ContentStorage.Load(provider, url); Defensive patterns
Strategy: try-catch
Validate before calling
// pre-validate file size and (if available) a known whole-file hash before load
if (!File.Exists(url) || new FileInfo(url).Length == 0)
throw new FileNotFoundException("Bundle missing or empty, repackage needed", url); Try / catch
try { storage = ContentStorage.Load(provider, url); }
catch (ContentStreamingException ex) when (ex.Message == "Invalid hash code.") {
logger.Error($"Bundle {url} corrupted; repackage or restore from a known-good build.");
} Prevention
- Checksum bundles after download/copy and before first load
- Never hand-edit .pkt files; always repackage via the asset compiler
- Handle crashes during packaging by cleaning partial artifacts
When it happens
Trigger: Opening a corrupted or partially written .pkt storage file; editing/serializing the storage with a mismatched Stride version; a failed download/copy leaving a stale index.
Common situations: Crash during asset packaging leaving an inconsistent bundle; syncing content files across versions where the header layout or hash algorithm changed; disk corruption.
Understand the failure class
Background: Checksum mismatch errors: "checksum verification failed", "digest mismatch", "expected vs actual checksum" — what they mean and how to fix them — this error's family across 41 libraries.
Related errors
- Missing file provider.
- Invalid storage offset.
- Unable to find a serializer for
- Unable to find a serializer for the specified asset. No…
- Unable to find a serializer for
AI-assisted analysis of stride3d/stride@96fad776d2 (2026-09-14).
Data as JSON: /api/errors/b01a6057c194b6ff.
Report an issue: GitHub.
Appendix: source
Thrown at sources/core/Stride.Core.Serialization/Streaming/ContentStorage.cs:81
internal ContentStorage(ContentStreamingService service)
{
Service = service;
}
internal void Init(ref ContentStorageHeader header)
{
Url = header.DataUrl;
chunks = new ContentChunk[header.ChunksCount];
for (int i = 0; i < chunks.Length; i++)
{
var e = header.Chunks[i];
chunks[i] = new ContentChunk(this, e.Location, e.Size);
}
PackageTime = header.PackageTime;
// Validate hash code
if (GetHashCode() != header.HashCode)
throw new ContentStreamingException("Invalid hash code.", this);
}
/// <summary>
/// Gets the chunk.
/// </summary>
/// <param name="index">The index.</param>
/// <returns>Chunk</returns>
public ContentChunk GetChunk(int index)
{
var chunk = chunks[index];
chunk.RegisterUsage();
return chunk;
}
internal void ReleaseUnusedChunks()
{
if (Interlocked.Read(ref locks) != 0)
return;View on GitHub (pinned to 96fad776d2)