{"record":{"id":"5347ac8ee1fb072e","repo":"hyperledger/fabric","slug":"error-unmarshalling-hashedrwset","errorCode":null,"errorMessage":"error unmarshalling HashedRWSet","messagePattern":"error unmarshalling HashedRWSet","errorType":"error_code","errorClass":null,"httpStatus":null,"severity":"error","filePath":"protoutil/unmarshalers.go","lineNumber":193,"sourceCode":"// UnmarshalTxReadWriteSet unmarshals bytes to a TxReadWriteSet\nfunc UnmarshalTxReadWriteSet(bytes []byte) (*rwset.TxReadWriteSet, error) {\n\trws := &rwset.TxReadWriteSet{}\n\terr := proto.Unmarshal(bytes, rws)\n\treturn rws, errors.Wrap(err, \"error unmarshalling TxReadWriteSet\")\n}\n\n// UnmarshalKVRWSet unmarshals bytes to a KVRWSet\nfunc UnmarshalKVRWSet(bytes []byte) (*kvrwset.KVRWSet, error) {\n\trws := &kvrwset.KVRWSet{}\n\terr := proto.Unmarshal(bytes, rws)\n\treturn rws, errors.Wrap(err, \"error unmarshalling KVRWSet\")\n}\n\n// UnmarshalHashedRWSet unmarshals bytes to a HashedRWSet\nfunc UnmarshalHashedRWSet(bytes []byte) (*kvrwset.HashedRWSet, error) {\n\thrws := &kvrwset.HashedRWSet{}\n\terr := proto.Unmarshal(bytes, hrws)\n\treturn hrws, errors.Wrap(err, \"error unmarshalling HashedRWSet\")\n}\n\n// UnmarshalSignaturePolicy unmarshals bytes to a SignaturePolicyEnvelope\nfunc UnmarshalSignaturePolicy(bytes []byte) (*common.SignaturePolicyEnvelope, error) {\n\tsp := &common.SignaturePolicyEnvelope{}\n\terr := proto.Unmarshal(bytes, sp)\n\treturn sp, errors.Wrap(err, \"error unmarshalling SignaturePolicyEnvelope\")\n}\n\n// UnmarshalPayloadOrPanic unmarshals bytes to a Payload structure or panics\n// on error\nfunc UnmarshalPayloadOrPanic(encoded []byte) *common.Payload {\n\tpayload, err := UnmarshalPayload(encoded)\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\treturn payload\n}","sourceCodeStart":175,"sourceCodeEnd":211,"githubUrl":"https://github.com/hyperledger/fabric/blob/2736b63f8fd5932511d56fe68b7039d15977f7f6/protoutil/unmarshalers.go#L175-L211","documentation":"UnmarshalHashedRWSet wraps proto.Unmarshal failures for kvrwset.HashedRWSet bytes. It means the input bytes cannot be decoded as a HashedRWSet protobuf. Like the KVRWSet variant, it is thrown when callers pass the wrong message level or corrupted bytes.","triggerScenarios":"Calling UnmarshalHashedRWSet with CollHashedRwSets inner bytes instead of the HashedRWSet message, nil/empty bytes, or data from a different proto schema version.","commonSituations":"Private data collection RW set tooling, hashed RW set comparisons, or tests marshalling the wrong struct.","solutions":["Verify the bytes are HashedRWSet (the Rwset field of HashedWriteSet wrappers), not a nested collection set","Check len(bytes) > 0 before calling","Align fabric-protos versions between producer and consumer of the bytes","Log the failure with namespace/collection context to identify the corrupted slice"],"exampleFix":"// before\nhrws, err := protoutil.UnmarshalHashedRWSet(hashedRwSetBytes)\n// after\nif len(bytes) == 0 { return errors.New(\"empty hashed rwset bytes\") }\nhrws, err := protoutil.UnmarshalHashedRWSet(collHashedRwSet.Rwset)","handlingStrategy":"validation","validationCode":"func hasHashedRWSetBytes(b []byte) bool { return len(b) > 0 }","typeGuard":"func safeUnmarshalHashedRWS(b []byte) (hrws *kvrwset.HashedRWSet, ok bool) {\n    hrws, err := protoutil.UnmarshalHashedRWSet(b)\n    return hrws, err == nil && hrws != nil\n}","tryCatchPattern":"hrws, err := protoutil.UnmarshalHashedRWSet(bytes)\nif err != nil {\n    return nil, fmt.Errorf(\"undecodable hashed rwset: %w\", err)\n}","preventionTips":["Confirm you are at the HashedRWSet message level, not nested CollHashedRwSets","Check byte length before unmarshalling","Log collection context on failure for traceability","Keep fabric-protos aligned between writers and readers"],"tags":["protobuf","unmarshal","fabric","hashed-rwset"],"backgroundTag":"proto-unmarshal-failed","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"}