{"record":{"id":"b606df75c7efc43f","repo":"hyperledger/fabric","slug":"error-unmarshalling-chaincode-collection-config-pk","errorCode":null,"errorMessage":"error unmarshalling chaincode collection config pkg","messagePattern":"error unmarshalling chaincode collection config pkg","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"core/scc/lscc/deployedcc_infoprovider.go","lineNumber":153,"sourceCode":"\t}\n\tfor _, conf := range collConfigPkg.Config {\n\t\tstaticCollConfig := conf.GetStaticCollectionConfig()\n\t\tif staticCollConfig != nil && staticCollConfig.Name == collectionName {\n\t\t\treturn staticCollConfig, nil\n\t\t}\n\t}\n\treturn nil, nil\n}\n\nfunc fetchCollConfigPkg(chaincodeName string, qe ledger.SimpleQueryExecutor) (*peer.CollectionConfigPackage, error) {\n\tcollKey := privdata.BuildCollectionKVSKey(chaincodeName)\n\tcollectionConfigPkgBytes, err := qe.GetState(lsccNamespace, collKey)\n\tif err != nil || collectionConfigPkgBytes == nil {\n\t\treturn nil, err\n\t}\n\tcollectionConfigPkg := &peer.CollectionConfigPackage{}\n\tif err := proto.Unmarshal(collectionConfigPkgBytes, collectionConfigPkg); err != nil {\n\t\treturn nil, errors.Wrap(err, \"error unmarshalling chaincode collection config pkg\")\n\t}\n\treturn collectionConfigPkg, nil\n}\n","sourceCodeStart":135,"sourceCodeEnd":157,"githubUrl":"https://github.com/hyperledger/fabric/blob/2736b63f8fd5932511d56fe68b7039d15977f7f6/core/scc/lscc/deployedcc_infoprovider.go#L135-L157","documentation":"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.","triggerScenarios":"Calling ChaincodeInfo, AllCollectionsConfigPkg, or CollectionInfo when GetState(lsccNamespace, collKey) returns bytes that fail proto.Unmarshal into CollectionConfigPackage.","commonSituations":"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.","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"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"// Go: pre-check collection config bytes decode\ncollKey := buildCollectionConfigKey(chaincodeName)\nraw, err := qe.GetState(\"lscc\", collKey)\nif err != nil { return err }\nif raw != nil {\n    pkg := &peer.CollectionConfigPackage{}\n    if err := proto.Unmarshal(raw, pkg); err != nil {\n        return fmt.Errorf(\"corrupt collection config for %s: %w\", chaincodeName, err)\n    }\n}","typeGuard":null,"tryCatchPattern":"// Go\npkg, err := fetchCollConfigPkg(chaincodeName, qe)\nif err != nil {\n    if strings.Contains(err.Error(), \"unmarshalling chaincode collection config\") {\n        return fmt.Errorf(\"corrupt collection config package for %s: %w\", chaincodeName, err)\n    }\n    return err\n}","preventionTips":["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"],"tags":["hyperledger-fabric","protobuf","unmarshal","collections-config"],"backgroundTag":"protobuf-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"}