{"record":{"id":"3cb63c1f2d441cd3","repo":"hyperledger/fabric","slug":"unexpected-data-format-x","errorCode":null,"errorMessage":"unexpected data format: %x","messagePattern":"unexpected data format: %x","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"common/ledger/snapshot/file.go","lineNumber":149,"sourceCode":"\treusableByteSlice []byte\n}\n\n// OpenFile constructs a FileReader. This function returns an error if the format of the file, stored in the\n// first byte, does not match with the expectedDataFormat\nfunc OpenFile(filePath string, expectDataformat byte) (*FileReader, error) {\n\tfile, err := os.Open(filePath)\n\tif err != nil {\n\t\treturn nil, errors.Wrapf(err, \"error while opening the snapshot file: %s\", filePath)\n\t}\n\tbufReader := bufio.NewReader(file)\n\tdataFormat, err := bufReader.ReadByte()\n\tif err != nil {\n\t\tfile.Close()\n\t\treturn nil, errors.Wrapf(err, \"error while reading from the snapshot file: %s\", filePath)\n\t}\n\tif dataFormat != expectDataformat {\n\t\tfile.Close()\n\t\treturn nil, errors.New(fmt.Sprintf(\"unexpected data format: %x\", dataFormat))\n\t}\n\treturn &FileReader{\n\t\tfile:      file,\n\t\tbufReader: bufReader,\n\t}, nil\n}\n\n// DecodeString reads and decodes a string\nfunc (r *FileReader) DecodeString() (string, error) {\n\tb, err := r.decodeBytes()\n\treturn string(b), err\n}\n\n// DecodeBytes reads and decodes bytes\nfunc (r *FileReader) DecodeBytes() ([]byte, error) {\n\tb, err := r.decodeBytes()\n\tif err != nil {\n\t\treturn nil, err","sourceCodeStart":131,"sourceCodeEnd":167,"githubUrl":"https://github.com/hyperledger/fabric/blob/2736b63f8fd5932511d56fe68b7039d15977f7f6/common/ledger/snapshot/file.go#L131-L167","documentation":"OpenFile validates that the first byte of the snapshot file equals the expectedDataformat the caller requires. This error (built with errors.New, no inner cause) means the file's format byte differs — the snapshot was written with a different data format than the importer expects, or the file is not a valid snapshot at all.","triggerScenarios":"dataFormat != expectDataformat, e.g. importing a snapshot exported by a different Fabric version, or pointing OpenFile at a non-snapshot file whose first byte happens to be readable.","commonSituations":"Version skew between the peer that exported the snapshot and the one importing it; accidentally configuring a corrupted or unrelated file as the snapshot; endianness/format changes across releases.","solutions":["Verify the snapshot was exported by a compatible Fabric version and re-export if needed","Confirm the configured path points to the correct snapshot file (check the format byte with xxd/od)","Check what format the importer expects and confirm the snapshot's first byte matches (e.g. hex 00/01)"],"exampleFix":null,"handlingStrategy":"validation","validationCode":"f, _ := os.Open(path); defer f.Close()\nvar b [1]byte\nio.ReadFull(f, b[:])\nif b[0] != expectedFormat { return fmt.Errorf(\"format %x != expected %x\", b[0], expectedFormat) }","typeGuard":null,"tryCatchPattern":"fr, err := snapshot.OpenFile(path, expectedFmt)\nif err != nil {\n    if strings.Contains(err.Error(), \"unexpected data format\") {\n        return fmt.Errorf(\"snapshot %s incompatible with this peer version\", path)\n    }\n    return err\n}","preventionTips":["Export and import snapshots with the same Fabric release line","Record the export version alongside the snapshot","Validate the snapshot's first byte against the expected format before bootstrap"],"tags":["snapshot","format-mismatch","versioning","bootstrap"],"backgroundTag":"snapshot-format-mismatch","analyzedSha":"2736b63f8fd5932511d56fe68b7039d15977f7f6","analyzedAt":"2026-09-04T08:52:36.465Z","contentChangedAt":"2026-09-04T08:52:36.465Z","schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}