hyperledger/fabric · error
error unmarshalling chaincode collection config pkg
Error message
error unmarshalling chaincode collection config pkg
What it means
Raised by fetchCollConfigPkg in lscc when the collection configuration package bytes stored in the lscc namespace fail to proto-unmarshal into peer.CollectionConfigPackage. The stored collection config for the chaincode is corrupt or in an unexpected format, so collection configuration cannot be returned.
Source
Thrown at core/scc/lscc/deployedcc_infoprovider.go:153
}
for _, conf := range collConfigPkg.Config {
staticCollConfig := conf.GetStaticCollectionConfig()
if staticCollConfig != nil && staticCollConfig.Name == collectionName {
return staticCollConfig, nil
}
}
return nil, nil
}
func fetchCollConfigPkg(chaincodeName string, qe ledger.SimpleQueryExecutor) (*peer.CollectionConfigPackage, error) {
collKey := privdata.BuildCollectionKVSKey(chaincodeName)
collectionConfigPkgBytes, err := qe.GetState(lsccNamespace, collKey)
if err != nil || collectionConfigPkgBytes == nil {
return nil, err
}
collectionConfigPkg := &peer.CollectionConfigPackage{}
if err := proto.Unmarshal(collectionConfigPkgBytes, collectionConfigPkg); err != nil {
return nil, errors.Wrap(err, "error unmarshalling chaincode collection config pkg")
}
return collectionConfigPkg, nil
}
View on GitHub (pinned to 2736b63f8f)
Solutions
- Inspect the wrapped proto error to confirm which field/encoding failed
- Re-define the chaincode's collections config so a valid CollectionConfigPackage is written to lscc state
- Restore the state database from a consistent backup
- Verify no external process wrote raw/non-proto bytes under the lscc coll key
Defensive patterns
Strategy: try-catch
Validate before calling
// Go: pre-check collection config bytes decode
collKey := buildCollectionConfigKey(chaincodeName)
raw, err := qe.GetState("lscc", collKey)
if err != nil { return err }
if raw != nil {
pkg := &peer.CollectionConfigPackage{}
if err := proto.Unmarshal(raw, pkg); err != nil {
return fmt.Errorf("corrupt collection config for %s: %w", chaincodeName, err)
}
} Try / catch
// Go
pkg, err := fetchCollConfigPkg(chaincodeName, qe)
if err != nil {
if strings.Contains(err.Error(), "unmarshalling chaincode collection config") {
return fmt.Errorf("corrupt collection config package for %s: %w", chaincodeName, err)
}
return err
} Prevention
- Always write collection configs through lscc's supported APIs, never direct state writes
- Keep collection config schema compatible across Fabric upgrades
- Validate collection config packages (configtxlator / proto validation) before commit
- Rebuild state DB from blockchain if corruption is suspected
When it happens
Trigger: Calling ChaincodeInfo, AllCollectionsConfigPkg, or CollectionInfo when GetState(lsccNamespace, collKey) returns bytes that fail proto.Unmarshal into CollectionConfigPackage.
Common situations: Corrupted collection config records in the ledger; state written by a different Fabric release with an incompatible CollectionConfigPackage encoding; manual ledger edits or a bad restore.
Understand the failure class
Background: "cannot parse invalid wire-format data", "cannot unmarshal", "failed unmarshalling": protobuf unmarshal errors explained — this error's family across 10 libraries.
Related errors
- failed to deserialize values
- error converting envelope to config update: %s
- failed to unmarshal response for transaction %s
- unmarshalling ChaincodeQueryResponse failed
- could not unmarshal chaincode package to CDS or SignedCDS
AI-assisted analysis of hyperledger/fabric@2736b63f8f (2026-09-04).
Data as JSON: /api/errors/b606df75c7efc43f.
Report an issue: GitHub.