{"record":{"id":"c133d9b6976d458e","repo":"hyperledger/fabric","slug":"error-marshalling-default-instantiation-policy","errorCode":null,"errorMessage":"error marshalling default instantiation policy","messagePattern":"error marshalling default instantiation policy","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"core/scc/lscc/support.go","lineNumber":66,"sourceCode":"func (s *SupportImpl) GetInstantiationPolicy(channel string, ccpack ccprovider.CCPackage) ([]byte, error) {\n\tvar ip []byte\n\tvar err error\n\t// if ccpack is a SignedCDSPackage, return its IP, otherwise use a default IP\n\tsccpack, isSccpack := ccpack.(*ccprovider.SignedCDSPackage)\n\tif isSccpack {\n\t\tip = sccpack.GetInstantiationPolicy()\n\t\tif ip == nil {\n\t\t\treturn nil, errors.Errorf(\"instantiation policy cannot be nil for a SignedCCDeploymentSpec\")\n\t\t}\n\t} else {\n\t\t// the default instantiation policy allows any of the channel MSP admins\n\t\t// to be able to instantiate\n\t\tmspids := s.GetMSPIDs(channel)\n\n\t\tp := policydsl.SignedByAnyAdmin(mspids)\n\t\tip, err = protoutil.Marshal(p)\n\t\tif err != nil {\n\t\t\treturn nil, errors.Errorf(\"error marshalling default instantiation policy\")\n\t\t}\n\t}\n\treturn ip, nil\n}\n\n// CheckInstantiationPolicy checks whether the supplied signed proposal\n// complies with the supplied instantiation policy\nfunc (s *SupportImpl) CheckInstantiationPolicy(signedProp *pb.SignedProposal, chainName string, instantiationPolicy []byte) error {\n\t// create a policy object from the policy bytes\n\tidd := s.GetIdentityDeserializer(chainName)\n\tif idd == nil {\n\t\treturn errors.Errorf(\"error checking chaincode instantiation policy: MSP manager for channel %s not found\", chainName)\n\t}\n\tnpp := cauthdsl.NewPolicyProvider(idd)\n\tinstPol, _, err := npp.NewPolicy(instantiationPolicy)\n\tif err != nil {\n\t\treturn err\n\t}","sourceCodeStart":48,"sourceCodeEnd":84,"githubUrl":"https://github.com/hyperledger/fabric/blob/2736b63f8fd5932511d56fe68b7039d15977f7f6/core/scc/lscc/support.go#L48-L84","documentation":"GetInstantiationPolicy builds a default instantiation policy (SignedByAnyAdmin of the channel's MSP IDs) and marshals it to protobuf bytes. This error is returned if protoutil.Marshal fails on that generated policy object. In practice it almost never fires because the policy is constructed internally, but it guards against serialization failures.","triggerScenarios":"Calling GetInstantiationPolicy for a chaincode with no explicit instantiation policy, when the internally generated SignedByAnyAdmin policy cannot be marshalled (e.g. corrupted MSP IDs list or internal protobuf issue).","commonSituations":"Rare; seen during chaincode install/instantiate flows on channels whose MSP configuration is anomalous, or in forked/patched builds where policy types changed.","solutions":["Retry the chaincode install/instantiate operation; the failure is usually transient or internal","Verify channel MSP configuration is valid (mspids list is well-formed)","Update to a patched Fabric version if the marshal error is reproducible"],"exampleFix":null,"handlingStrategy":"retry","validationCode":"// ensure channel MSP IDs are available before defaulting to implicit policy\nif len(s.GetMSPIDs(channel)) == 0 {\n    return nil, errors.Errorf(\"no MSP IDs found for channel %s\", channel)\n}","typeGuard":null,"tryCatchPattern":"ip, err := support.GetInstantiationPolicy(channel, ccdata)\nif err != nil {\n    return fmt.Errorf(\"failed to get instantiation policy: %w\", err)\n}","preventionTips":["Ensure channel MSP configuration is valid before deploy","Retry transient marshal failures","Keep Fabric version current to avoid internal serialization bugs"],"tags":["fabric","lscc","serialization"],"backgroundTag":"protobuf-marshalling-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"}