{"record":{"id":"0ab1b9c32d012ade","repo":"hyperledger/fabric","slug":"collection-config-policy-is-nil","errorCode":null,"errorMessage":"Collection config policy is nil","messagePattern":"Collection config policy is nil","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"core/common/privdata/simplecollection.go","lineNumber":96,"sourceCode":"// IsMemberOnlyWrite returns whether only collection member\n// has the write permission\nfunc (sc *SimpleCollection) IsMemberOnlyWrite() bool {\n\treturn sc.conf.MemberOnlyWrite\n}\n\n// Setup configures a simple collection object based on a given\n// StaticCollectionConfig proto that has all the necessary information\nfunc (sc *SimpleCollection) Setup(collectionConfig *peer.StaticCollectionConfig, deserializer msp.IdentityDeserializer) error {\n\tif collectionConfig == nil {\n\t\treturn errors.New(\"Nil config passed to collection setup\")\n\t}\n\tsc.conf = proto.Clone(collectionConfig).(*peer.StaticCollectionConfig)\n\tsc.name = collectionConfig.GetName()\n\n\t// get the access signature policy envelope\n\tcollectionPolicyConfig := collectionConfig.GetMemberOrgsPolicy()\n\tif collectionPolicyConfig == nil {\n\t\treturn errors.New(\"Collection config policy is nil\")\n\t}\n\taccessPolicyEnvelope := collectionPolicyConfig.GetSignaturePolicy()\n\tif accessPolicyEnvelope == nil {\n\t\treturn errors.New(\"Collection config access policy is nil\")\n\t}\n\n\terr := sc.setupAccessPolicy(collectionPolicyConfig, deserializer)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\t// get member org MSP IDs from the envelope, identities that fail to deserialize will not be returned\n\tsc.memberOrgs = getMemberOrgs(accessPolicyEnvelope.Identities, deserializer)\n\n\treturn nil\n}\n\n// setupAccessPolicy configures a simple collection object based on a given","sourceCodeStart":78,"sourceCodeEnd":114,"githubUrl":"https://github.com/hyperledger/fabric/blob/2736b63f8fd5932511d56fe68b7039d15977f7f6/core/common/privdata/simplecollection.go#L78-L114","documentation":"Setup requires the StaticCollectionConfig to carry a MemberOrgsPolicy defining which organizations may access the private data. This error fires when collectionConfig.GetMemberOrgsPolicy() returns nil, i.e., the collection was defined without specifying member organizations. Without this policy the access filter cannot be built.","triggerScenarios":"A collections_config.json entry lacking the \"memberOrgsPolicy\" (or the policy field omitted when constructing StaticCollectionConfig in code), passed to NewSimpleCollection/Setup via chaincode collection configuration.","commonSituations":"Hand-written or templated collections.json where memberOrgsPolicy.signaturePolicy was dropped, tooling that builds CollectionConfigPackage programmatically and skips MemberOrgsPolicy, config truncated during approval.","solutions":["Add a memberOrgsPolicy (with a valid signaturePolicy listing member org MSPs) to every collection in the collections config","Re-package and re-approve the chaincode definition with the corrected collections config","Validate the CollectionConfigPackage (e.g., ValidateCollectionConfig) before submitting"],"exampleFix":"// before\n{\n  \"name\": \"coll1\",\n  \"requiredPeerCount\": 1\n}\n\n// after\n{\n  \"name\": \"coll1\",\n  \"requiredPeerCount\": 1,\n  \"memberOrgsPolicy\": {\n    \"signaturePolicy\": { \"identities\": [...], \"policy\": {...} }\n  }\n}","handlingStrategy":"validation","validationCode":"for _, c := range collections {\n  if c.GetMemberOrgsPolicy() == nil {\n    return fmt.Errorf(\"collection %q missing memberOrgsPolicy\", c.GetName())\n  }\n}","typeGuard":"func hasMemberOrgsPolicy(c *peer.StaticCollectionConfig) bool {\n  return c != nil && c.GetMemberOrgsPolicy() != nil\n}","tryCatchPattern":"if err := sc.Setup(cfg, deserializer); err != nil {\n  if strings.Contains(err.Error(), \"policy is nil\") {\n    return fmt.Errorf(\"fix collections config: %w\", err)\n  }\n  return err\n}","preventionTips":["Use the documented collections.json schema with memberOrgsPolicy on every entry","Run ValidateCollectionConfig on the package before approval","Schema-check (jq/JSON schema) collection configs in CI"],"tags":["privdata","collection-config","policy"],"backgroundTag":"missing-collection-policy","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"}