> ## Content Index
> Fetch the complete content index at: https://datajutsu.com/llms.txt
> Use this file to discover other available public pages before exploring further.

# The Avro Container Has No Checksum (and the Only Safety Net Is a Random Sixteen Bytes)
- URL: https://datajutsu.com/avro-container-no-checksum/
- Published: 2026-10-25T09:56:29.000Z
- Updated: 2026-10-25T09:56:29.000Z
- Author: Data Jutsu

You open an Avro file and the schema is already in it. That is the first thing that makes it different from a protobuf file, and it is the thing the format never stops doing. A .pb file is raw message bytes. No magic number, no header, no length field, no marker telling you where the message ends. The bytes are only as good as the .proto you bring to them, and that schema-relative decoding is the whole subject of the [unknown fields post](https://datajutsu.com/protobuf-unknown-fields-streaming/). An .avro file is the opposite. It opens with four bytes, Obj and a one, and the header that follows is a map that carries the codec and the full schema as a string. I built a two record file and walked it back by hand. Before a single record, the header holds the codec, null, and the schema as a 119 byte string. The file describes itself. That is the reason schema evolution can do what the [schema evolution post](https://datajutsu.com/avro-schema-evolution/) describes, and it is the reason the bytes at rest are never schema relative the way protobuf bytes are.

Here is the part I keep coming back to. For the null codec, the container has no checksum. Not on the header, not on the block, nowhere in the file. The only structural signal is a sixteen byte marker, written right after the header and again after every data block. And the marker is not a hash of the data. It is random. I generated three files with the same schema and the same two records, and the three markers were three different strings of bytes. So the file is not checking that your data is intact. It is checking that the data is in order. A block ends where the marker reappears. If a write is cut off mid block, the next sixteen bytes will not match the marker, and that is the only error you get. The safety net is not a digest of what you wrote. It is a landmark you compare the file against. Miss the landmark and you know the file stopped.

The blocks are where the framing gets specific, and there is a trap in the second field. Each block is a long for the number of records, a long for the size, then the block data. That size long is the number of bytes the block data occupies on disk, which for a compressed codec is the compressed length. For the null codec it happens to equal the record stream length, so it reads like the data length and everyone assumes it is. It is not. I checked the writer that produces these files. For null it writes the raw record length, for deflate it writes the length of the deflated bytes. The reader uses the size to know how many bytes to consume before the next marker, and the record count to know how many records to expect. Confuse the two and a deflate block that shrinks the data reads the wrong number of bytes and the whole file slides out of alignment. A few codecs do carry a checksum, and it lives inside the block, not in the framing. Snappy writes a four byte CRC after the compressed data, and the writer counts those four bytes in the size. That tells you the framing has no integrity of its own. The checksum is a feature of the codec, and the thing the format itself relies on is the marker.

There is a cost to all of this, and it shows up the moment the data is small. My two record file is 204 bytes. Fifteen of those are the records. The schema string is 119 bytes, more than half the file. So the container spent 58 percent of its own bytes describing itself, and the data is less than a tenth of the whole. A protobuf message for the same two records is just the record bytes, no framing at all. The self description and the clean end marker are a premium. When the payload is small, the label is bigger than what it labels. That is not a bug, that is the format doing what it does.

The compression knob does not save you on small data either. I wrote the same two records with deflate instead of null and the file got bigger, 212 bytes to 204\. A fifteen byte record stream is too small for the compressor to help, so the deflate output was a few bytes longer than the raw data, and the codec name is longer than null. Compression level only matters when the block is big enough to have something to squeeze, and the file size is the number to watch, not the codec you asked for.

That is the difference the cross format post only had room to name. The two formats agree on a double and disagree on an integer, but they never share a container, because one is a bare message and the other is a file that knows its own schema and its own end. If you are debugging an .avro file a pipeline half wrote, start at the last marker and walk back to the final block, and if that marker is missing the file is cut, no digest needed. Put a schema and some bytes in [proto.datajutsu.com](https://proto.datajutsu.com/?ref=datajutsu.com) and the converter shows you both sides of the same record, and for the container the whole question of is this file intact comes down to one thing. Does the marker come back.