abpframework/abp · error · AbpException
The encrypted BLOB is corrupted or has an invalid format: tr
Error message
The encrypted BLOB is corrupted or has an invalid format: truncated chunk!
What it means
GetCipherChunkSize requires at least ChunkLengthPrefixSize (4) bytes for the length prefix. Fewer than that means the chunk header was cut off mid-prefix — the stream ended partway through reading the length, so the chunk is truncated and cannot be parsed.
Source
Thrown at framework/src/Volo.Abp.BlobStoring/Volo/Abp/BlobStoring/BlobEncryptionCodec.cs:531
if (chunkIndex < 0)
{
// A wrapped chunk index would repeat a nonce for the same key, which breaks AES-GCM.
throw new AbpException("The data is too large: the maximum chunk count has been exceeded!");
}
WriteInt32BigEndian(nonceOrAssociatedData, nonceOrAssociatedData.Length - 4, chunkIndex);
}
internal static int GetCipherChunkSize(byte[] lengthPrefix, int maxCipherChunkSize)
{
if (lengthPrefix.Length == 0)
{
throw new AbpException("The encrypted BLOB is corrupted or has an invalid format: missing terminal record!");
}
if (lengthPrefix.Length < ChunkLengthPrefixSize)
{
throw new AbpException("The encrypted BLOB is corrupted or has an invalid format: truncated chunk!");
}
var cipherChunkSize = ReadInt32BigEndian(lengthPrefix, 0);
if (cipherChunkSize < 0 || cipherChunkSize > maxCipherChunkSize)
{
throw new AbpException("The encrypted BLOB is corrupted or has an invalid format: invalid chunk length!");
}
return cipherChunkSize;
}
internal static byte[]? ReadExactly(Stream stream, int count)
{
var buffer = ReadUpTo(stream, count);
return buffer.Length == count ? buffer : null;
}
internal static byte[] ReadUpTo(Stream stream, int count)View on GitHub (pinned to 7ed43b1931)
Solutions
- Re-upload the BLOB from a known-good source.
- Verify storage-level object integrity (checksums, ETag, content-length).
- Check for storage-side corruption or replication lag serving a stale partial object.
- Ensure the writer and reader use the same codec version and chunk format.
Example fix
// before — reading from an unverified source
using var s = await provider.GetStreamAsync(name);
var plain = await DecryptAsync(s); // throws [89]
// after — verify length first
var info = await provider.GetOrNullAsync(name);
if (info == null || info.ContentLength < MinimumCipherLength)
throw new InvalidOperationException("corrupt or truncated blob"); Defensive patterns
Strategy: try-catch
Validate before calling
// Reject objects whose length cannot contain even one length prefix.
var info = await provider.GetOrNullAsync(name);
if (info == null || info.ContentLength < 4 /* ChunkLengthPrefixSize */)
throw new InvalidOperationException($"BLOB '{name}' is too short to contain a valid chunk header."); Type guard
public sealed record MinLengthBlob(string Name, long ContentLength)
{
public static MinLengthBlob Check(string name, long len)
{
const int MinCipherLen = 16; // magic + at least a length prefix
if (len < MinCipherLen) throw new InvalidOperationException("blob too short");
return new MinLengthBlob(name, len);
}
} Try / catch
try
{
return await blob.GetAllBytesAsync(name);
}
catch (AbpException ex) when (ex.Message.Contains("truncated chunk"))
{
logger.LogError(ex, "BLOB '{Name}' truncated mid-header; re-upload.", name);
throw;
} Prevention
- Verify object content-length against expectations before decrypting.
- Store ETag/checksums and validate them on read.
- Re-upload truncated objects rather than retrying reads.
- Match writer and reader codec versions.
When it happens
Trigger: Decrypting a BLOB where the cipher stream ends after 1–3 bytes of a length prefix instead of the full 4 (e.g. truncation in the middle of a chunk boundary).
Common situations: Truncated object in storage; partial download; byte-level corruption that altered boundaries; mismatched format version producing wrong offsets.
Related errors
- The encrypted BLOB is corrupted or has an invalid format: mi
- The encrypted BLOB is corrupted or has an invalid format: tr
- The encrypted BLOB is corrupted or has an invalid format: in
- The encrypted BLOB is corrupted or has an invalid format: in
- The stream can not be read anymore, because a previous read
AI-assisted analysis of abpframework/abp@7ed43b1931 (2026-08-13).
Data as JSON: /api/errors/1e4541d2419c4639.
Report an issue: GitHub.