{"record":{"id":"680973bbf87b5eba","repo":"hyperledger/fabric","slug":"error-unmarshalling-block","errorCode":null,"errorMessage":"error unmarshalling Block","messagePattern":"error unmarshalling Block","errorType":"error_code","errorClass":null,"httpStatus":null,"severity":"error","filePath":"protoutil/unmarshalers.go","lineNumber":26,"sourceCode":"\nimport (\n\t\"github.com/hyperledger/fabric-protos-go-apiv2/common\"\n\t\"github.com/hyperledger/fabric-protos-go-apiv2/ledger/rwset\"\n\t\"github.com/hyperledger/fabric-protos-go-apiv2/ledger/rwset/kvrwset\"\n\t\"github.com/hyperledger/fabric-protos-go-apiv2/msp\"\n\t\"github.com/hyperledger/fabric-protos-go-apiv2/peer\"\n\t\"github.com/pkg/errors\"\n\t\"google.golang.org/protobuf/proto\"\n)\n\n// the implicit contract of all these unmarshalers is that they\n// will return a non-nil pointer whenever the error is nil\n\n// UnmarshalBlock unmarshals bytes to a Block\nfunc UnmarshalBlock(encoded []byte) (*common.Block, error) {\n\tblock := &common.Block{}\n\terr := proto.Unmarshal(encoded, block)\n\treturn block, errors.Wrap(err, \"error unmarshalling Block\")\n}\n\n// UnmarshalChaincodeDeploymentSpec unmarshals bytes to a ChaincodeDeploymentSpec\nfunc UnmarshalChaincodeDeploymentSpec(code []byte) (*peer.ChaincodeDeploymentSpec, error) {\n\tcds := &peer.ChaincodeDeploymentSpec{}\n\terr := proto.Unmarshal(code, cds)\n\treturn cds, errors.Wrap(err, \"error unmarshalling ChaincodeDeploymentSpec\")\n}\n\n// UnmarshalChaincodeInvocationSpec unmarshals bytes to a ChaincodeInvocationSpec\nfunc UnmarshalChaincodeInvocationSpec(encoded []byte) (*peer.ChaincodeInvocationSpec, error) {\n\tcis := &peer.ChaincodeInvocationSpec{}\n\terr := proto.Unmarshal(encoded, cis)\n\treturn cis, errors.Wrap(err, \"error unmarshalling ChaincodeInvocationSpec\")\n}\n\n// UnmarshalPayload unmarshals bytes to a Payload\nfunc UnmarshalPayload(encoded []byte) (*common.Payload, error) {","sourceCodeStart":8,"sourceCodeEnd":44,"githubUrl":"https://github.com/hyperledger/fabric/blob/2736b63f8fd5932511d56fe68b7039d15977f7f6/protoutil/unmarshalers.go#L8-L44","documentation":"UnmarshalBlock wraps a proto.Unmarshal failure: the encoded bytes are not a valid protobuf-encoded common.Block (empty, truncated, or different message type). Callers inspecting blocks from envelopes or files rely on this to reject malformed data.","triggerScenarios":"Thrown at protoutil/unmarshalers.go:26 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Verify the byte slice is a complete, uncorrupted block payload","Check the producer/consumer agree on the Fabric protobuf versions"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"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"}