hyperledger/fabric · error
error unmarshalling HashedRWSet
Error message
error unmarshalling HashedRWSet
What it means
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.
Source
Thrown at protoutil/unmarshalers.go:193
// UnmarshalTxReadWriteSet unmarshals bytes to a TxReadWriteSet
func UnmarshalTxReadWriteSet(bytes []byte) (*rwset.TxReadWriteSet, error) {
rws := &rwset.TxReadWriteSet{}
err := proto.Unmarshal(bytes, rws)
return rws, errors.Wrap(err, "error unmarshalling TxReadWriteSet")
}
// UnmarshalKVRWSet unmarshals bytes to a KVRWSet
func UnmarshalKVRWSet(bytes []byte) (*kvrwset.KVRWSet, error) {
rws := &kvrwset.KVRWSet{}
err := proto.Unmarshal(bytes, rws)
return rws, errors.Wrap(err, "error unmarshalling KVRWSet")
}
// UnmarshalHashedRWSet unmarshals bytes to a HashedRWSet
func UnmarshalHashedRWSet(bytes []byte) (*kvrwset.HashedRWSet, error) {
hrws := &kvrwset.HashedRWSet{}
err := proto.Unmarshal(bytes, hrws)
return hrws, errors.Wrap(err, "error unmarshalling HashedRWSet")
}
// UnmarshalSignaturePolicy unmarshals bytes to a SignaturePolicyEnvelope
func UnmarshalSignaturePolicy(bytes []byte) (*common.SignaturePolicyEnvelope, error) {
sp := &common.SignaturePolicyEnvelope{}
err := proto.Unmarshal(bytes, sp)
return sp, errors.Wrap(err, "error unmarshalling SignaturePolicyEnvelope")
}
// UnmarshalPayloadOrPanic unmarshals bytes to a Payload structure or panics
// on error
func UnmarshalPayloadOrPanic(encoded []byte) *common.Payload {
payload, err := UnmarshalPayload(encoded)
if err != nil {
panic(err)
}
return payload
}View on GitHub (pinned to 2736b63f8f)
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
Example fix
// before
hrws, err := protoutil.UnmarshalHashedRWSet(hashedRwSetBytes)
// after
if len(bytes) == 0 { return errors.New("empty hashed rwset bytes") }
hrws, err := protoutil.UnmarshalHashedRWSet(collHashedRwSet.Rwset) Defensive patterns
Strategy: validation
Validate before calling
func hasHashedRWSetBytes(b []byte) bool { return len(b) > 0 } Type guard
func safeUnmarshalHashedRWS(b []byte) (hrws *kvrwset.HashedRWSet, ok bool) {
hrws, err := protoutil.UnmarshalHashedRWSet(b)
return hrws, err == nil && hrws != nil
} Try / catch
hrws, err := protoutil.UnmarshalHashedRWSet(bytes)
if err != nil {
return nil, fmt.Errorf("undecodable hashed rwset: %w", err)
} Prevention
- 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
When it happens
Trigger: Calling UnmarshalHashedRWSet with CollHashedRwSets inner bytes instead of the HashedRWSet message, nil/empty bytes, or data from a different proto schema version.
Common situations: Private data collection RW set tooling, hashed RW set comparisons, or tests marshalling the wrong struct.
Related errors
- error unmarshalling
- error unmarshalling original config
- error unmarshalling updated config
- failed to unmarshal ApplicationPolicy bytes
- could not unmarshal signature policy envelope
AI-assisted analysis of hyperledger/fabric@2736b63f8f (2026-09-04).
Data as JSON: /api/errors/5347ac8ee1fb072e.
Report an issue: GitHub.