hyperledger/fabric · error

Collection config policy is nil

Error message

Collection config policy is nil

What it means

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.

Source

Thrown at core/common/privdata/simplecollection.go:96

// IsMemberOnlyWrite returns whether only collection member
// has the write permission
func (sc *SimpleCollection) IsMemberOnlyWrite() bool {
	return sc.conf.MemberOnlyWrite
}

// Setup configures a simple collection object based on a given
// StaticCollectionConfig proto that has all the necessary information
func (sc *SimpleCollection) Setup(collectionConfig *peer.StaticCollectionConfig, deserializer msp.IdentityDeserializer) error {
	if collectionConfig == nil {
		return errors.New("Nil config passed to collection setup")
	}
	sc.conf = proto.Clone(collectionConfig).(*peer.StaticCollectionConfig)
	sc.name = collectionConfig.GetName()

	// get the access signature policy envelope
	collectionPolicyConfig := collectionConfig.GetMemberOrgsPolicy()
	if collectionPolicyConfig == nil {
		return errors.New("Collection config policy is nil")
	}
	accessPolicyEnvelope := collectionPolicyConfig.GetSignaturePolicy()
	if accessPolicyEnvelope == nil {
		return errors.New("Collection config access policy is nil")
	}

	err := sc.setupAccessPolicy(collectionPolicyConfig, deserializer)
	if err != nil {
		return err
	}

	// get member org MSP IDs from the envelope, identities that fail to deserialize will not be returned
	sc.memberOrgs = getMemberOrgs(accessPolicyEnvelope.Identities, deserializer)

	return nil
}

// setupAccessPolicy configures a simple collection object based on a given

View on GitHub (pinned to 2736b63f8f)

Solutions

  1. Add a memberOrgsPolicy (with a valid signaturePolicy listing member org MSPs) to every collection in the collections config
  2. Re-package and re-approve the chaincode definition with the corrected collections config
  3. Validate the CollectionConfigPackage (e.g., ValidateCollectionConfig) before submitting

Example fix

// before
{
  "name": "coll1",
  "requiredPeerCount": 1
}

// after
{
  "name": "coll1",
  "requiredPeerCount": 1,
  "memberOrgsPolicy": {
    "signaturePolicy": { "identities": [...], "policy": {...} }
  }
}
Defensive patterns

Strategy: validation

Validate before calling

for _, c := range collections {
  if c.GetMemberOrgsPolicy() == nil {
    return fmt.Errorf("collection %q missing memberOrgsPolicy", c.GetName())
  }
}

Type guard

func hasMemberOrgsPolicy(c *peer.StaticCollectionConfig) bool {
  return c != nil && c.GetMemberOrgsPolicy() != nil
}

Try / catch

if err := sc.Setup(cfg, deserializer); err != nil {
  if strings.Contains(err.Error(), "policy is nil") {
    return fmt.Errorf("fix collections config: %w", err)
  }
  return err
}

Prevention

When it happens

Trigger: 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.

Common situations: Hand-written or templated collections.json where memberOrgsPolicy.signaturePolicy was dropped, tooling that builds CollectionConfigPackage programmatically and skips MemberOrgsPolicy, config truncated during approval.

Related errors


AI-assisted analysis of hyperledger/fabric@2736b63f8f (2026-09-04). Data as JSON: /api/errors/0ab1b9c32d012ade. Report an issue: GitHub.