{"record":{"id":"567942f4a6b17869","repo":"hyperledger/fabric","slug":"unexpected-error-while-unmarshalling-bytes-v-i-567942","errorCode":null,"errorMessage":"unexpected error while unmarshalling bytes [%#v] into fileLocPointer","messagePattern":"unexpected error while unmarshalling bytes \\[%#v\\] into fileLocPointer","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"common/ledger/blkstorage/blockindex.go","lineNumber":525,"sourceCode":"\tflp.bytesLength = relativeLP.bytesLength\n\treturn flp\n}\n\nfunc (flp *fileLocPointer) marshal() []byte {\n\tvar buf []byte\n\tbuf = protowire.AppendVarint(buf, uint64(flp.fileSuffixNum))\n\tbuf = protowire.AppendVarint(buf, uint64(flp.offset))\n\tbuf = protowire.AppendVarint(buf, uint64(flp.bytesLength))\n\n\treturn buf\n}\n\nfunc (flp *fileLocPointer) unmarshal(b []byte) error {\n\tvar position int\n\n\ti, n := protowire.ConsumeVarint(b[position:])\n\tif n < 0 {\n\t\treturn errors.Wrapf(protowire.ParseError(n), \"unexpected error while unmarshalling bytes [%#v] into fileLocPointer\", b)\n\t}\n\tposition += n\n\tflp.fileSuffixNum = int(i)\n\n\ti, n = protowire.ConsumeVarint(b[position:])\n\tif n < 0 {\n\t\treturn errors.Wrapf(protowire.ParseError(n), \"unexpected error while unmarshalling bytes [%#v] into fileLocPointer\", b)\n\t}\n\tposition += n\n\tflp.offset = int(i)\n\n\ti, n = protowire.ConsumeVarint(b[position:])\n\tif n < 0 {\n\t\treturn errors.Wrapf(protowire.ParseError(n), \"unexpected error while unmarshalling bytes [%#v] into fileLocPointer\", b)\n\t}\n\tflp.bytesLength = int(i)\n\treturn nil\n}","sourceCodeStart":507,"sourceCodeEnd":543,"githubUrl":"https://github.com/hyperledger/fabric/blob/2736b63f8fd5932511d56fe68b7039d15977f7f6/common/ledger/blkstorage/blockindex.go#L507-L543","documentation":"fileLocPointer.unmarshal decodes a protowire-encoded sequence of three varints (fileSuffixNum, offset, bytesLength) from the index DB value. When the first varint cannot be consumed (malformed protobuf wire data), the parse error is wrapped with this message. It indicates the stored index value is not a valid fileLocPointer encoding.","triggerScenarios":"Called from getBlockLocByHash, getBlockLocByBlockNum, getTxLoc, getBlockLocByTxID, or getTXLocByBlockNumTranNum when the index DB value under the looked-up key is corrupted, empty/truncated, or was written by an incompatible encoding version.","commonSituations":"LevelDB corruption after unclean shutdown, mixed-version ledgers where the value encoding changed, manually copied ledger directories missing/corrupting index values.","solutions":["Inspect the %#v bytes in the message to confirm the value is garbage/empty rather than valid varints.","Rebuild the block index: stop the peer, delete the index DB (or the whole ledgerDB), and resync/rejoin the channel.","Confirm all peers/ledgers come from compatible Fabric versions; do not mix ledger files across versions without migration.","Check for disk errors or unclean shutdowns that may have corrupted the store."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"loc := &blkstorage.FileLocPointer{}\nif err := loc.Unmarshal(indexValue); err != nil {\n    if strings.Contains(err.Error(), \"unexpected error while unmarshalling bytes\") {\n        return fmt.Errorf(\"corrupt index value for key %x: %w — schedule index rebuild\", key, err)\n    }\n    return err\n}","preventionTips":["Shut the peer down cleanly; avoid killing the process during index writes.","Monitor the ledger volume for disk errors and space pressure.","Never share or copy ledgerData files across incompatible Fabric versions.","Have a documented index-rebuild/rejoin procedure ready."],"tags":["protobuf","leveldb","blockstorage","corruption"],"backgroundTag":"index-value-corruption","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"}